Files
kotlin/compiler/testData/codegen/box/inlineClasses/boxResultInlineClassOfConstructorCall.kt
Dmitry Petrov a2900282fd Call factory method for primary constructors of inner classes
We might want to add 'init' blocks later, so now, for the sake of
binary compatibility with 1.3-RC binaries, we have to generate these
'constructor' calls.

Note that in some tests inline class boxing is no longer redundant,
because resulting value is passed to 'constructor' as an argument.
2018-09-05 12:20:57 +03:00

25 lines
620 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
inline 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"
}