Support equals/hashCode for fun interfaces in JVM and JVM_IR
#KT-33455 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
de461dd9a5
commit
9fa8e009c6
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// FILE: test.kt
|
||||
|
||||
fun checkNotEqual(x: Any, y: Any) {
|
||||
if (x == y || y == x) throw AssertionError("$x and $y should NOT be equal")
|
||||
}
|
||||
|
||||
private fun id(f: Runnable): Any = f
|
||||
|
||||
val lambda = {}
|
||||
|
||||
fun box(): String {
|
||||
// Since 1.0, SAM wrappers for Java do not implement equals/hashCode
|
||||
checkNotEqual(id(lambda), id(lambda))
|
||||
checkNotEqual(id(lambda), lambdaFromOtherFile())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: fromOtherFile.kt
|
||||
|
||||
private fun id(f: Runnable): Any = f
|
||||
|
||||
fun lambdaFromOtherFile(): Any = id(lambda)
|
||||
Reference in New Issue
Block a user