Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/castInsideWhenExpression.kt
T
Mikhail Zarechenskiy 8d24ca65a3 Propagate KotlinType into when expression codegen
This commit removes unneeded boxing when result expression of `when` is
 value of inline class type
2018-07-10 23:10:57 +03:00

19 lines
337 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
inline class Foo<T>(val x: Any) {
fun bar() {}
}
fun <T, K> transform(f: Foo<T>): Foo<K> {
return when {
true -> f as Foo<K>
else -> TODO()
}
}
fun box(): String {
val f = Foo<Int>(42)
val t = transform<Int, Number>(f)
return if (t.x !is Number) "Fail" else "OK"
}