Files
kotlin/compiler/testData/codegen/box/objects/object.kt
Mikhael Bogdanov b73be50e5b Move object initialization from <init> to <clinit>
Codegen generates static backing fields for object properties.
  They are initialized in class constructor but some of them are final static
  and such access is prohibited in specification but it's allowed in
  java bytecode <= 1.8. Such access in 1.9 bytecode cause
  "IllegalAccessError: Update to static final field Object.INSTANCE
  attempted from a different method (<init>) than the initializer method <clinit>"

  Added additional hidden field in interface companion to pass out
  companion instance from <clinit>.

 #KT-15894 Fixed
2017-10-11 19:20:24 +03:00

15 lines
217 B
Kotlin
Vendored

var result = ""
object A {
val prop = test()
fun test(): String {
result += "OK"
return result
}
}
fun box(): String {
if (A.prop != "OK") return "fail ${A.prop}"
return result
}