Files
kotlin-fork/compiler/testData/codegen/box/funInterface/equality/lambdaRuntimeConversion.kt
T
2021-10-08 07:24:41 +03:00

34 lines
800 B
Kotlin
Vendored

// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: IGNORED_IN_JS
// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6
// FILE: test.kt
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 checkNotEqual(x: Any, y: Any) {
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal")
}
fun interface FunInterface {
fun invoke()
}
private fun id(f: FunInterface): Any = f
val lambda = {}
fun box(): String {
checkEqual(id(lambda), id(lambda))
checkEqual(id(lambda), lambdaFromOtherFile())
return "OK"
}
// FILE: fromOtherFile.kt
private fun id(f: FunInterface): Any = f
fun lambdaFromOtherFile(): Any = id(lambda)