JVM_IR: permit @NoArg if super constructor is already zero-argument

#KT-46537 Fixed
This commit is contained in:
pyos
2021-05-07 10:44:00 +02:00
committed by Alexander Udalov
parent ac9e8f667d
commit 36a25353e9
5 changed files with 46 additions and 63 deletions
+22
View File
@@ -0,0 +1,22 @@
// WITH_RUNTIME
annotation class NoArg
open class Base1
open class Base2(val a: Int = 1)
open class Base3(val a: Int) {
@JvmOverloads constructor(a: Long = 1L) : this(a.toInt())
}
@NoArg class Test1(val b: String) : Base1()
@NoArg class Test2(val b: String) : Base2()
@NoArg class Test3(val b: String) : Base3()
fun box(): String {
val test1 = Test1::class.java.newInstance()
val test2 = Test2::class.java.newInstance()
if (test2.a != 1) return "fail@test2: ${test2.a}"
val test3 = Test3::class.java.newInstance()
if (test3.a != 1) return "fail@test3: ${test3.a}"
return "OK"
}