Unbox inline class parameter of lambda if underlying type is Any or Any?
The inline class is boxed when we pass it as lambda argument, now we unbox it. If the underlying type is not Any or Any?, bridge method does the unboxing. #KT-32450 Fixed #KT-39923 Fixed #KT-32228 Fixed #KT-40282 Fixed
This commit is contained in:
+47
@@ -0,0 +1,47 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
fun <T> underlying(a: IC): T = bar(a) {
|
||||
it.value as T
|
||||
}
|
||||
|
||||
fun <T> extension(a: IC): T = bar(a) {
|
||||
it.extensionValue()
|
||||
}
|
||||
|
||||
fun <T> dispatch(a: IC): T = bar(a) {
|
||||
it.dispatchValue()
|
||||
}
|
||||
|
||||
fun <T> normal(a: IC): T = bar(a) {
|
||||
normalValue(it)
|
||||
}
|
||||
|
||||
fun <T, R> bar(value: T, f: (T) -> R): R {
|
||||
return f(value)
|
||||
}
|
||||
|
||||
fun <T> IC.extensionValue(): T = value as T
|
||||
|
||||
fun <T> normalValue(ic: IC): T = ic.value as T
|
||||
|
||||
inline class IC(val value: String) {
|
||||
fun <T> dispatchValue(): T = value as T
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = underlying<String>(IC("O")) + "K"
|
||||
if (res != "OK") return "FAIL 1: $res"
|
||||
|
||||
res = extension<String>(IC("O")) + "K"
|
||||
if (res != "OK") return "FAIL 2: $res"
|
||||
|
||||
res = dispatch<String>(IC("O")) + "K"
|
||||
if (res != "OK") return "FAIL 3: $res"
|
||||
|
||||
res = normal<String>(IC("O")) + "K"
|
||||
if (res != "OK") return "FAIL 3: $res"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user