36b8ba8df3
- Ensure that typed equals parameter's type is a star projection of corresponding inline class - Make possible to declare typed equals that returns 'Nothing' - Forbid type parameters in typed equals operator declaration ^KT-54909 fixed ^KT-54910 fixed
22 lines
481 B
Kotlin
Vendored
22 lines
481 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) {
|
|
operator 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"
|
|
} |