JVM JVM_IR hide sealed class constructors

This commit is contained in:
Dmitry Petrov
2021-01-22 15:31:56 +03:00
parent ca3bb02897
commit 708e6914bd
27 changed files with 555 additions and 97 deletions
@@ -0,0 +1,24 @@
// TARGET_BACKEND: JVM
// WITH_REFLECT
annotation class Ann
sealed class Test @Ann constructor(@Ann val x: String)
fun box(): String {
val testCtor = Test::class.constructors.single()
val testCtorAnnClasses = testCtor.annotations.map { it.annotationClass }
if (testCtorAnnClasses != listOf(Ann::class)) {
throw AssertionError("Annotations on constructor: $testCtorAnnClasses")
}
for (param in testCtor.parameters) {
val paramAnnClasses = param.annotations.map { it.annotationClass }
if (paramAnnClasses != listOf(Ann::class)) {
throw AssertionError("Annotations on constructor parameter $param: $paramAnnClasses")
}
}
return "OK"
}
@@ -0,0 +1,7 @@
sealed class Sealed(val value: String) {
constructor() : this("OK")
}
class Derived : Sealed()
fun box() = Derived().value
@@ -0,0 +1,38 @@
class B : A()
sealed class A() {
constructor(i: Int): this()
class C: A()
}
object T : Y()
class D : A(4)
class E : A {
constructor(i: Int): super(i)
constructor(): super()
}
object S : Z()
sealed class Y : X()
sealed class Z : Y()
sealed class X : A()
class Q : Y()
fun box() : String {
B()
A.C()
D()
E()
E(4)
T
S
Q()
return "OK"
}