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,29 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
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
|
||||
|
||||
fun box(): String {
|
||||
// Since 1.0, SAM wrappers for Java do not implement equals/hashCode
|
||||
|
||||
fun local1() {}
|
||||
fun local2() {}
|
||||
|
||||
checkNotEqual(id(::local1), id(::local1))
|
||||
checkNotEqual(id(::local1), id(::local2))
|
||||
|
||||
fun String.localExt() {}
|
||||
|
||||
checkNotEqual(id("A"::localExt), id("A"::localExt))
|
||||
checkNotEqual(id("A"::localExt), id("B"::localExt))
|
||||
|
||||
fun adapted(default: String? = "", vararg va: Int): Int = 0
|
||||
|
||||
checkNotEqual(id(::adapted), id(::adapted))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user