9ef89447b3
Before this commit, sealed sub-class without state was considered a style issue. After this commit, sealed sub-class without state AND custom equals is considered a probable bug, because comparison of its instances is very fragile. Alternative fix (generate equals & hashCode by identity) is added.
18 lines
316 B
Kotlin
Vendored
18 lines
316 B
Kotlin
Vendored
// PROBLEM: none
|
|
|
|
abstract class Base {
|
|
open val prop: Int
|
|
get() = 13
|
|
|
|
override fun equals(other: Any?): Boolean {
|
|
if (other !is Base) return false
|
|
return prop == other.prop
|
|
}
|
|
}
|
|
|
|
sealed class SC : Base() {
|
|
<caret>class U : SC()
|
|
|
|
override val prop: Int
|
|
get() = 42
|
|
} |