mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
36 lines
557 B
Kotlin
Vendored
36 lines
557 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// WITH_RUNTIME
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
class WithCompanion {
|
|
companion object {
|
|
var a = 0
|
|
init {
|
|
a++
|
|
}
|
|
@JvmField var b = a
|
|
init {
|
|
b++
|
|
}
|
|
val c = b
|
|
}
|
|
}
|
|
|
|
object Object {
|
|
var a = 0
|
|
init {
|
|
a++
|
|
}
|
|
@JvmField var b = a
|
|
init {
|
|
b++
|
|
}
|
|
val c = b
|
|
}
|
|
|
|
fun box(): String {
|
|
assertEquals<Int>(2, WithCompanion.c, "Field WithCompanion.c")
|
|
assertEquals<Int>(2, Object.c, "Field Object")
|
|
return "OK"
|
|
} |