Files
kotlin-fork/compiler/testData/diagnostics/tests/sealed/Local.kt
T
Mikhail Glukhikh 8d25c20169 Introduction of sealed classes
Sealed classes can be derived only by their own inner classes or objects.
Their constructors cannot be called explicitly, so compiler knows all their descendants.
Incompatible modifier checks (final, abstract). Impossible with interface, object, enum.
A pack of tests provided.
2015-06-25 19:07:13 +03:00

14 lines
458 B
Kotlin
Vendored

sealed class Sealed {
object First: Sealed()
open class NonFirst: Sealed() {
object Second: NonFirst()
object Third: NonFirst()
fun foo(): Int {
val s = object: <!SEALED_SUPERTYPE_IN_LOCAL_CLASS!>Sealed<!>() {}
class Local: <!SEALED_SUPERTYPE_IN_LOCAL_CLASS!>Sealed<!>() {}
return s.hashCode()
}
}
val p: Sealed = object: <!SEALED_SUPERTYPE_IN_LOCAL_CLASS!>Sealed<!>() {}
}