KT-43941 [Sealed interfaces]: subclass intention

Restriction for sealed inheritors was relaxed. Instead of being nested
class members now they can be the members of the same module and
package.
This commit is contained in:
Andrei Klunnyi
2020-12-22 12:59:27 +01:00
parent 1cac8b0d61
commit 3f287d344e
11 changed files with 116 additions and 17 deletions
+8
View File
@@ -0,0 +1,8 @@
// "Implement sealed class" "true"
// WITH_RUNTIME
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// COMPILER_ARGUMENTS: -XXLanguage:+SealedInterfaces
sealed class <caret>Base {
abstract fun foo(): Int
}
+14
View File
@@ -0,0 +1,14 @@
// "Implement sealed class" "true"
// WITH_RUNTIME
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// COMPILER_ARGUMENTS: -XXLanguage:+SealedInterfaces
sealed class Base {
abstract fun foo(): Int
}
class BaseImpl : Base() {
override fun foo(): Int {
TODO("Not yet implemented")
}
}
@@ -0,0 +1,4 @@
// "Implement sealed class" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// COMPILER_ARGUMENTS: -XXLanguage:+SealedInterfaces
sealed class <caret>Sealed
@@ -0,0 +1,5 @@
// "Implement sealed class" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// COMPILER_ARGUMENTS: -XXLanguage:+SealedInterfaces
sealed class Sealed
<caret>class SealedImpl : Sealed()
@@ -0,0 +1,12 @@
// "Implement sealed class" "true"
// WITH_RUNTIME
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// COMPILER_ARGUMENTS: -XXLanguage:+SealedInterfaces
sealed class <caret>Base {
abstract fun foo(): Int
class BaseImpl : Base() {
override fun foo() = throw UnsupportedOperationException()
}
}
@@ -0,0 +1,18 @@
// "Implement sealed class" "true"
// WITH_RUNTIME
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// COMPILER_ARGUMENTS: -XXLanguage:+SealedInterfaces
sealed class Base {
abstract fun foo(): Int
class BaseImpl : Base() {
override fun foo() = throw UnsupportedOperationException()
}
}
class BaseImpl : Base() {
override fun foo(): Int {
TODO("Not yet implemented")
}
}