Files
kotlin-fork/compiler/testData/codegen/box/sam/javaSamWithEqualsHashCode/classImplementingFunctionInterface.kt
T
2022-03-03 09:01:42 +00:00

26 lines
533 B
Kotlin
Vendored

// !LANGUAGE: +JavaSamConversionEqualsHashCode
// TARGET_BACKEND: JVM_IR
// FULL_JDK
class F(val v: String) : () -> Unit {
override fun invoke() {}
override fun equals(other: Any?): Boolean =
other is F && other.v == v
override fun hashCode(): Int =
v.hashCode()
}
fun box(): String {
val r1 = Runnable(F("abc"))
val r2 = Runnable(F("abc"))
if (r1 != r2)
return "r1 != r2"
if (r1.hashCode() != r2.hashCode())
return "r1.hashCode() != r2.hashCode()"
return "OK"
}