Propagate KotlinType into when expression codegen

This commit removes unneeded boxing when result expression of `when` is
 value of inline class type
This commit is contained in:
Mikhail Zarechenskiy
2018-07-10 15:44:43 +03:00
parent 35b2b762cd
commit 8d24ca65a3
7 changed files with 46 additions and 2 deletions
@@ -0,0 +1,18 @@
// !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"
}