Files
kotlin-fork/compiler/testData/diagnostics/tests/inlineClasses/illegalEqualsOverridingInInlineClass.kt
T
vladislav.grechko e0c8142106 Support of custom 'equals' and 'hashCode' in inline classes
'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
2022-10-10 16:52:34 +00:00

28 lines
586 B
Kotlin
Vendored

// FIR_IDENTICAL
// WITH_STDLIB
// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST
// LANGUAGE: +CustomEqualsInInlineClasses
@JvmInline
value class IC1(val x: Int) {
<!INEFFICIENT_EQUALS_OVERRIDING_IN_INLINE_CLASS!>override fun equals(other: Any?): Boolean<!> {
if (other !is IC1) {
return false
}
return x == other.x
}
}
@JvmInline
value class IC2(val x: Int) {
override fun hashCode() = 0
}
@JvmInline
value class IC3(val x: Int) {
override fun equals(other: Any?) = true
fun equals(other: IC3) = true
override fun hashCode() = 0
}