JVM_IR: remove a hack from InlineCallableReferenceToLambda

It breaks other things, the same problem is hit by FunctionReference,
and it's the translation layer's fault anyway.

 #KT-46555 Fixed
This commit is contained in:
pyos
2021-05-10 11:52:31 +02:00
committed by teamcityserver
parent cff74b31d4
commit a37db99841
11 changed files with 111 additions and 20 deletions
@@ -1,13 +1,11 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: CALLABLE_REFERENCES_FAIL
inline fun <TT> id(x: TT): TT = x
inline fun <TT> String.extId(x: TT): String = this
fun <T> id(x: T): T = x
fun <T> String.extId(x: T): T = x
private fun <T> ff(value: T?): String {
// In PSI2IR, the funcref is approximated to Function1<Nothing, Pair<String, T>>
value?.let(::id)
return value?.let("OK"::extId)!!
}
fun box() = ff("arg")
fun <T> foo(value: T?): T? = value?.let(::id) // KFunction1<Nothing, T>
fun <T> bar(value: T?): T? = value?.let(""::extId)
fun box() = foo("O")!! + foo("K")!!
@@ -0,0 +1,13 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: CALLABLE_REFERENCES_FAIL
fun <T> id(x: T): T = x
fun <T> String.extId(x: T): T = x
fun <T, R> T.myLet(block: (T) -> R): R = block(this)
fun <T> foo(value: T?): T? = value?.myLet(::id) // KFunction1<Nothing, T>
fun <T> bar(value: T?): T? = value?.myLet(""::extId)
fun box() = foo("O")!! + foo("K")!!
@@ -0,0 +1,28 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// MODULE: lib
// FILE: X.java
package test;
public class X extends PX {
public X(String x) { super(x); }
}
// FILE: PX.java
package test;
class PX {
private final String x;
PX(String x) { this.x = x; }
public String foo() { return x; }
}
// MODULE: main(lib)
// FILE: box.kt
import test.X
fun <T, R> T.myLet(block: (T) -> R): R = block(this)
fun box() = X("O").let(X::foo) + X("K").myLet(X::foo)