[FE] Prohibit inheritance of sealed classes in different module

KT-20423
This commit is contained in:
Dmitriy Novozhilov
2020-11-24 14:42:10 +03:00
committed by TeamCityServer
parent f8d6f79c17
commit 57a081c399
17 changed files with 232 additions and 0 deletions
@@ -0,0 +1,7 @@
package a
sealed class Base
sealed interface IBase
class A : Base(), IBase
@@ -0,0 +1,5 @@
// ISSUE: KT-20423
package a
class B : Base(), IBase
@@ -0,0 +1,20 @@
warning: ATTENTION!
This build uses unsafe internal compiler arguments:
-XXLanguage:+FreedomForSealedClasses
-XXLanguage:+SealedInterfaces
This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!
compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/main.kt:5:11: error: cannot access '<init>': it is internal in 'Base'
class B : Base(), IBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/main.kt:5:11: error: inheritance of sealed classes or interfaces from different module is prohibited
class B : Base(), IBase
^
compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/main.kt:5:19: error: inheritance of sealed classes or interfaces from different module is prohibited
class B : Base(), IBase
^
COMPILATION_ERROR
@@ -0,0 +1,17 @@
// ISSUE: KT-20423
// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses
// MODULE: m1
// FILE: a.kt
package a
sealed class Base
class A : Base()
// MODULE: m2(m1)
// FILE: b.kt
package a
class B : <!HIDDEN!>Base<!>()
@@ -0,0 +1,17 @@
// ISSUE: KT-20423
// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses
// MODULE: m1
// FILE: a.kt
package a
sealed class Base
class A : Base()
// MODULE: m2(m1)
// FILE: b.kt
package a
class B : <!INVISIBLE_MEMBER, SEALED_INHERITOR_IN_DIFFERENT_MODULE!>Base<!>()
@@ -0,0 +1,33 @@
// -- Module: <m1> --
package
package a {
public final class A : a.Base {
public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public sealed class Base {
internal constructor Base()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
// -- Module: <m2> --
package
package a {
public final class B : a.Base {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,17 @@
// ISSUE: KT-20423
// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses
// MODULE: m1
// FILE: a.kt
package a
sealed interface Base
interface A : Base
// MODULE: m2(m1)
// FILE: b.kt
package a
interface B : Base
@@ -0,0 +1,17 @@
// ISSUE: KT-20423
// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses
// MODULE: m1
// FILE: a.kt
package a
sealed interface Base
interface A : Base
// MODULE: m2(m1)
// FILE: b.kt
package a
interface B : <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>Base<!>
@@ -0,0 +1,30 @@
// -- Module: <m1> --
package
package a {
public interface A : a.Base {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public sealed interface Base {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
// -- Module: <m2> --
package
package a {
public interface B : a.Base {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}