[K/N] Fix work with adapted function references

Their parsing was totally incorrect for K2, and sometimes incorrect for
K1. After this commit it uses same code as for JVM.

^KT-55462
This commit is contained in:
Pavel Kunyavskiy
2023-01-24 12:42:19 +01:00
committed by Space Team
parent 9a693fa967
commit cb655d2d37
25 changed files with 292 additions and 32 deletions
@@ -1,9 +1,19 @@
// !LANGUAGE: +SuspendConversion
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: FAILS_IN_JS_IR
// IGNORE_BACKEND: JS, JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// FILE: suspendCovnersion.kt
fun checkNotEqual(x: Any, y: Any) {
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal")
}
fun checkEqual(x: Any, y: Any) {
if (x != y || y != x) throw AssertionError("$x and $y should be equal")
if (x.hashCode() != y.hashCode()) throw AssertionError("$x and $y should have the same hash code")
}
fun capturePlain(fn: () -> Unit): Any = fn
fun captureSuspend(fn: suspend () -> Unit): Any = fn
@@ -26,18 +36,30 @@ fun box(): String {
val c = C()
checkNotEqual(capturePlain(::foo), captureSuspend(::foo))
checkEqual(capturePlain(::foo), capturePlain(::foo))
checkEqual(captureSuspend(::foo), captureSuspend(::foo))
checkNotEqual(capturePlain(c::memberFun), captureSuspend(c::memberFun))
checkEqual(capturePlain(c::memberFun), capturePlain(c::memberFun))
checkEqual(captureSuspend(c::memberFun), captureSuspend(c::memberFun))
checkNotEqual(captureOther1(), captureOther2())
checkNotEqual(captureBoundOther1(c), captureBoundOther2(c))
checkNotEqual(capturePlainInt(::fnWithVararg), captureSuspendInt(::fnWithVararg))
checkNotEqual(captureSuspend(::fnWithVararg), captureSuspendInt(::fnWithVararg))
checkEqual(capturePlainInt(::fnWithVararg), capturePlainInt(::fnWithVararg))
checkEqual(captureSuspendInt(::fnWithVararg), captureSuspendInt(::fnWithVararg))
checkEqual(captureSuspend(::fnWithVararg), captureSuspend(::fnWithVararg))
checkNotEqual(capturePlainInt(::fnWithDefault), captureSuspendInt(::fnWithDefault))
checkNotEqual(captureSuspend(::fnWithDefault), captureSuspendInt(::fnWithDefault))
checkEqual(capturePlainInt(::fnWithDefault), capturePlainInt(::fnWithDefault))
checkEqual(captureSuspendInt(::fnWithDefault), captureSuspendInt(::fnWithDefault))
checkEqual(captureSuspend(::fnWithDefault), captureSuspend(::fnWithDefault))
checkNotEqual(capturePlain(::fnReturnsInt), captureSuspend(::fnReturnsInt))
checkEqual(capturePlain(::fnReturnsInt), capturePlain(::fnReturnsInt))
checkEqual(captureSuspend(::fnReturnsInt), captureSuspend(::fnReturnsInt))
return "OK"
}