Files
kotlin-fork/idea/testData/inspectionsLocal/convertSealedSubClassToObject/fakeState.kt
T
Mikhail Glukhikh 9ef89447b3 Sealed sub-class -> object: handle equals, suggest "add equals"
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.
2018-06-19 11:20:26 +03:00

19 lines
339 B
Kotlin
Vendored

// FIX: Convert sealed sub-class to object
// WITH_RUNTIME
abstract class Base {
var s: String
get() = "Hello"
set(value) {}
}
sealed class Sealed : Base() {
open val x: List<Int>
get() = emptyList()
}
<caret>class Derived : Sealed() {
var length: Int
get() = s.length
set(value) {}
}