e0c8142106
'equals' from any made available for overriding in inline classes 'typed' equals made available for definition in inline classes 'typed' equals definition made compulsory if 'untyped' is overridden 'operator' keyword is allowed in 'typed' equals definition ^KT-24874: Fixed
22 lines
472 B
Kotlin
Vendored
22 lines
472 B
Kotlin
Vendored
// WITH_STDLIB
|
|
// WORKS_WHEN_VALUE_CLASS
|
|
// LANGUAGE: +ValueClasses, +CustomEqualsInInlineClasses
|
|
// TARGET_BACKEND: JVM_IR
|
|
|
|
import kotlin.math.abs
|
|
|
|
OPTIONAL_JVM_INLINE_ANNOTATION
|
|
value class IC(val x: Double) {
|
|
fun equals(other: IC): Boolean {
|
|
return abs(x - other.x) < 0.1
|
|
}
|
|
|
|
override fun hashCode(): Int {
|
|
return 0
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val set = setOf(IC(1.0), IC(1.5), IC(1.501))
|
|
return if (set.size == 2) "OK" else "Fail"
|
|
} |