KT-36024 Generate adapted callable references as lambdas
Make sure both JVM and JVM_IR use the same information to determine whether a callable reference requires argument adaptation.
This commit is contained in:
committed by
Alexander Udalov
parent
ddf7f53118
commit
d1c5a42124
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
import kotlin.reflect.KCallable
|
||||
|
||||
fun checkUnit(label: String, fn: () -> Unit) {
|
||||
if (fn is KCallable<*>) {
|
||||
throw AssertionError("$label is KCallable, ${fn::class.java.simpleName}")
|
||||
}
|
||||
}
|
||||
|
||||
fun checkAny(label: String, fn: () -> Any) {
|
||||
if (fn is KCallable<*>) {
|
||||
throw AssertionError("$label is KCallable, ${fn::class.java.simpleName}")
|
||||
}
|
||||
}
|
||||
|
||||
fun withDefaults(a: Int = 1, b: Int = 2) {}
|
||||
fun withVarargs(vararg xs: Int) {}
|
||||
fun withCoercion() = 1
|
||||
|
||||
class CWithDefaults(x: Int = 1, y: Int = 2)
|
||||
class CWithVarargs(vararg xs: Int)
|
||||
|
||||
fun box(): String {
|
||||
checkUnit("::withDefaults", ::withDefaults)
|
||||
checkUnit("::withVarargs", ::withVarargs)
|
||||
checkUnit("::withCoercion", ::withCoercion)
|
||||
|
||||
checkAny("::CWithDefaults", ::CWithDefaults)
|
||||
checkAny("::CWithVarargs", ::CWithVarargs)
|
||||
|
||||
// TODO KT-37604
|
||||
// checkUnit("::CWithDefaults", ::CWithDefaults)
|
||||
// checkUnit("::CWithVarargs", ::CWithVarargs)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user