Fix KotlinType of constructor call for inline classes
This commit is contained in:
+17
@@ -4,20 +4,37 @@ inline class Result<T>(val a: Any?) {
|
||||
fun typed(): T = a as T
|
||||
}
|
||||
|
||||
fun <T> takeResult(r: Result<T>) {}
|
||||
fun takeResultOfInt(r: Result<Int>) {}
|
||||
fun takeInt(i: Int) {}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val asInt = Result<Int>(19)
|
||||
val asString = Result<String>("sample")
|
||||
val asResult = Result<Result<Int>>(asInt)
|
||||
val asResultCtor = Result<Result<Int>>(Result<Int>(10))
|
||||
|
||||
takeResult(asInt)
|
||||
takeResult(asString)
|
||||
takeResult(asResult)
|
||||
takeResult(asResultCtor)
|
||||
|
||||
takeResultOfInt(asInt)
|
||||
takeInt(asInt.typed())
|
||||
|
||||
val unboxedInt = asInt.typed()
|
||||
val unboxedString = asString.typed()
|
||||
val unboxedResult = asResult.typed()
|
||||
val unboxedAsCtor = asResultCtor.typed()
|
||||
|
||||
if (unboxedInt != 19) return "fail"
|
||||
if (unboxedString != "sample") return "fail"
|
||||
if (unboxedResult.typed() != 19) return "fail"
|
||||
if (unboxedAsCtor.typed() != 10) return "fail"
|
||||
|
||||
if (asResult.typed().typed() != 19) return "fail"
|
||||
if (asResultCtor.typed().typed() != 10) return "fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class Result<T>(val a: Any?)
|
||||
|
||||
fun test() {
|
||||
val a = Result<Int>(1) // valueOf
|
||||
val b = Result<String>("sample")
|
||||
|
||||
val c = Result<Result<Int>>(a) // box
|
||||
val d = Result<Result<Int>>(Result<Int>(1)) // valueOf, box
|
||||
}
|
||||
|
||||
// 2 INVOKESTATIC Result\$Erased.box
|
||||
// 0 INVOKEVIRTUAL Result.unbox
|
||||
|
||||
// 2 valueOf
|
||||
// 0 intValue
|
||||
Reference in New Issue
Block a user