NoArg: Do not invoke initializers by default. Require "invokeInitializers" option to be set explicitly (KT-18667, KT-18668)
This commit is contained in:
committed by
Yan Zhulanow
parent
a983137978
commit
b99007961f
+30
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user