mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
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.
25 lines
620 B
Kotlin
Vendored
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"
|
|
}
|