Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt
T
2021-10-11 12:09:52 +03:00

27 lines
689 B
Kotlin
Vendored

// WITH_RUNTIME
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@kotlin.jvm.JvmInline
value class Result<T>(val a: Any?)
fun box(): String {
val a = Result<Int>(1) // valueOf
val b = Result<String>("sample")
val c = Result<Result<Int>>(a)
val d = Result<Result<Int>>(Result<Int>(1)) // valueOf
if (a.a !is Int) throw AssertionError()
if (b.a !is String) throw AssertionError()
if (c.a !is Result<*>) throw AssertionError()
val ca = c.a as Result<*>
if (ca.a !is Int) throw AssertionError()
if (d.a !is Result<*>) throw AssertionError()
val da = d.a as Result<*>
if (da.a !is Int) throw AssertionError()
return "OK"
}