fa4a4e56f3
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com> #KT-1179
35 lines
982 B
Kotlin
Vendored
35 lines
982 B
Kotlin
Vendored
// WITH_REFLECT
|
|
// FULL_JDK
|
|
// LANGUAGE: +ValueClasses
|
|
// TARGET_BACKEND: JVM_IR
|
|
|
|
import java.lang.NullPointerException
|
|
import java.lang.reflect.InvocationTargetException
|
|
import kotlin.reflect.jvm.isAccessible
|
|
|
|
|
|
@JvmInline
|
|
value class IC(val str: String)
|
|
|
|
class A(val a: IC, val x : String) {
|
|
fun foo() = "$a$x"
|
|
|
|
private constructor(x: IC) : this(IC(""), "")
|
|
}
|
|
|
|
inline fun assertThrowsExpectedException(block: () -> Unit): Boolean {
|
|
try {
|
|
block()
|
|
} catch (t: Throwable) {
|
|
return t is InvocationTargetException && t.targetException is NullPointerException
|
|
}
|
|
return false
|
|
}
|
|
|
|
fun box(): String {
|
|
if (!assertThrowsExpectedException { ::A.call(null, "").foo() }) return "Fail 1"
|
|
if (!assertThrowsExpectedException { ::A.call(IC(""), null).foo() }) return "Fail 2"
|
|
val privateConstructor = A::class.constructors.single { it.parameters.size == 1 }
|
|
privateConstructor.also { it.isAccessible = true }.call(null).foo()
|
|
return "OK"
|
|
} |