NoArg: Initialize properties in noarg constructor (KT-16692)

This commit is contained in:
Yan Zhulanow
2017-05-04 17:55:35 +03:00
parent eba5baa7ff
commit 254e8156ac
13 changed files with 243 additions and 140 deletions
+35
View File
@@ -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
View File
@@ -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"
}
}