Fix unboxing values of inline class type from type parameters

This commit is contained in:
Mikhail Zarechenskiy
2018-02-19 19:43:55 +03:00
parent 99cea07bf4
commit 530dd01ca6
9 changed files with 88 additions and 1 deletions
@@ -0,0 +1,28 @@
// !LANGUAGE: +InlineClasses
inline class Result<T>(val a: Any?) {
fun typed(): T = a as T
}
fun <K> materialize(): K = TODO()
fun test(asInt: Result<Int>, asString: Result<String>, asResult: Result<Result<Int>>) {
val a1 = materialize<Result<Int>>() // unbox
val a2 = materialize<Result<Result<Int>>>() // unbox
val b1 = asInt.typed() // intValue
val b2 = asString.typed()
val c1 = asResult.typed() // unbox
materialize<Result<Int>>()
asInt.typed()
asString.typed()
asResult.typed()
}
// 0 INVOKESTATIC Result\$Erased.box
// 3 INVOKEVIRTUAL Result.unbox
// 0 valueOf
// 1 intValue