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,23 @@
// !LANGUAGE: +InlineClasses
inline class Result<T>(val a: Any?) {
fun typed(): T = a as T
}
fun box(): String {
val asInt = Result<Int>(19)
val asString = Result<String>("sample")
val asResult = Result<Result<Int>>(asInt)
val unboxedInt = asInt.typed()
val unboxedString = asString.typed()
val unboxedResult = asResult.typed()
if (unboxedInt != 19) return "fail"
if (unboxedString != "sample") return "fail"
if (unboxedResult.typed() != 19) return "fail"
if (asResult.typed().typed() != 19) return "fail"
return "OK"
}