NoArg: Initialize properties in noarg constructor (KT-16692)
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
class Simple(val a: String)
|
||||
|
||||
@NoArg
|
||||
class Test(val a: String) {
|
||||
val x = 5
|
||||
val y = Simple("Hello, world!")
|
||||
val z by lazy { "TEST" }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
val test = Test::class.java.newInstance()
|
||||
|
||||
if (test.x != 5) {
|
||||
return "Bad 5"
|
||||
}
|
||||
|
||||
if (test.y == null || test.y.a != "Hello, world!") {
|
||||
return "Bad Hello, world!"
|
||||
}
|
||||
|
||||
if (test.z != "TEST") {
|
||||
return "Bad TEST"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
return "Fail"
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
annotation class NoArg
|
||||
|
||||
@NoArg
|
||||
class Test(val a: String)
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
Test::class.java.newInstance()
|
||||
return "OK"
|
||||
} catch (_: Throwable) {
|
||||
return "Fail"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user