NoArg: Do not invoke initializers by default. Require "invokeInitializers" option to be set explicitly (KT-18667, KT-18668)

This commit is contained in:
Yan Zhulanow
2017-07-04 17:18:41 +03:00
committed by Yan Zhulanow
parent a983137978
commit b99007961f
14 changed files with 160 additions and 9 deletions
@@ -0,0 +1,30 @@
// WITH_RUNTIME
annotation class NoArg
class Simple(val a: String)
@NoArg
class Test(val a: String) {
val x = 5
val y: Simple? = Simple("Hello, world!")
}
fun box(): String {
try {
val test = Test::class.java.newInstance()
if (test.x != 0) {
return "Bad 5"
}
if (test.y != null) {
return "Bad Hello, world!"
}
return "OK"
} catch (e: Throwable) {
e.printStackTrace()
return "Fail"
}
}