mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
34 lines
642 B
Kotlin
Vendored
34 lines
642 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// FILE: CompanionInitialization.java
|
|
|
|
public class CompanionInitialization {
|
|
|
|
public static Object getCompanion() {
|
|
return ConcreteWithStatic.Companion;
|
|
}
|
|
|
|
}
|
|
|
|
// FILE: CompanionInitialization.kt
|
|
|
|
interface IStatic
|
|
|
|
open class Static(x: IStatic) {
|
|
fun doSth() {
|
|
}
|
|
}
|
|
|
|
class ConcreteWithStatic : IStatic {
|
|
companion object : Static(ConcreteWithStatic())
|
|
}
|
|
|
|
fun box(): String {
|
|
ConcreteWithStatic.doSth()
|
|
|
|
val companion: Any? = CompanionInitialization.getCompanion()
|
|
if (companion == null) return "fail 1"
|
|
if (companion != ConcreteWithStatic) return "fail 2"
|
|
|
|
return "OK"
|
|
}
|