diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java index c7fca35ba93..e204e3c0b48 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BodyResolver.java @@ -56,7 +56,7 @@ import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException; import java.util.*; -import static org.jetbrains.kotlin.config.LanguageFeature.FreedomForSealedClasses; +import static org.jetbrains.kotlin.config.LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage; import static org.jetbrains.kotlin.config.LanguageFeature.TopLevelSealedInheritance; import static org.jetbrains.kotlin.diagnostics.Errors.*; import static org.jetbrains.kotlin.resolve.BindingContext.*; @@ -637,7 +637,7 @@ public class BodyResolver { } if (containingDescriptor == null) { if ( - !languageVersionSettings.supportsFeature(FreedomForSealedClasses) || + !languageVersionSettings.supportsFeature(AllowSealedInheritorsInDifferentFilesOfSamePackage) || DescriptorUtils.isLocal(supertypeOwner) ) { trace.report(SEALED_SUPERTYPE.on(typeReference)); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt index 18cf3717c3d..9b77161e5ab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt @@ -392,7 +392,7 @@ class FunctionDescriptorResolver( resolveValueParameters(constructorDescriptor, parameterScope, valueParameters, trace, null), resolveVisibilityFromModifiers( modifierList, - DescriptorUtils.getDefaultConstructorVisibility(classDescriptor, languageVersionSettings.supportsFeature(LanguageFeature.FreedomForSealedClasses)) + DescriptorUtils.getDefaultConstructorVisibility(classDescriptor, languageVersionSettings.supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage)) ) ) constructor.returnType = classDescriptor.defaultType diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInheritorInSamePackageChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInheritorInSamePackageChecker.kt index 31be306ed15..4bfa3d70bf0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInheritorInSamePackageChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/SealedInheritorInSamePackageChecker.kt @@ -17,7 +17,7 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.getAbbreviatedTypeOrType object SealedInheritorInSamePackageChecker : DeclarationChecker { override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { - if (!context.languageVersionSettings.supportsFeature(LanguageFeature.FreedomForSealedClasses)) return + if (!context.languageVersionSettings.supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage)) return if (descriptor !is ClassDescriptor || declaration !is KtClassOrObject) return val classPackage = descriptor.containingPackage() ?: return // local class, SEALED_SUPERTYPE already reported for (superTypeListEntry in declaration.superTypeListEntries) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index 599982fff30..d6d9790b64a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -30,7 +30,6 @@ import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils; import org.jetbrains.kotlin.resolve.DescriptorUtils; -import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil; import org.jetbrains.kotlin.resolve.lazy.LazyClassContext; import org.jetbrains.kotlin.resolve.lazy.LazyEntity; @@ -270,7 +269,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes ) ); - boolean freedomForSealedInterfacesSupported = c.getLanguageVersionSettings().supportsFeature(LanguageFeature.FreedomForSealedClasses); + boolean freedomForSealedInterfacesSupported = c.getLanguageVersionSettings().supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage); this.sealedSubclasses = storageManager.createLazyValue(() -> c.getSealedClassInheritorsProvider().computeSealedSubclasses(this, freedomForSealedInterfacesSupported)); } diff --git a/compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt b/compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt index bdae46a7afe..ff712206259 100644 --- a/compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt +++ b/compiler/testData/codegen/box/sealed/multipleFiles_enabled.kt @@ -1,6 +1,6 @@ // ISSUE: KT-13495 // IGNORE_BACKEND_FIR: JVM_IR -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // FILE: Base.kt diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/output.txt index e4d9b26ce29..89bef39328d 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/sealedClassesAndInterfaces/output.txt @@ -1,7 +1,7 @@ warning: ATTENTION! This build uses unsafe internal compiler arguments: --XXLanguage:+FreedomForSealedClasses +-XXLanguage:+AllowSealedInheritorsInDifferentFilesOfSamePackage -XXLanguage:+SealedInterfaces This mode is not recommended for production use, diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt index 4f0b6da9911..b22e0dc8b0d 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/sealedInheritorInDifferentModule/output.txt @@ -1,7 +1,7 @@ warning: ATTENTION! This build uses unsafe internal compiler arguments: --XXLanguage:+FreedomForSealedClasses +-XXLanguage:+AllowSealedInheritorsInDifferentFilesOfSamePackage -XXLanguage:+SealedInterfaces This mode is not recommended for production use, diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt index 171f5f2e107..f90edc7720d 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.fir.kt @@ -1,6 +1,6 @@ // ISSUE: KT-13495 // !DIAGNOSTICS: -UNUSED_VARIABLE -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // FILE: Base.kt diff --git a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.kt b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.kt index fc58d0236cc..d72d40c9102 100644 --- a/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.kt +++ b/compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.kt @@ -1,6 +1,6 @@ // ISSUE: KT-13495 // !DIAGNOSTICS: -UNUSED_VARIABLE -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // FILE: Base.kt diff --git a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt index aa349ea0459..3300a9cb6aa 100644 --- a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.fir.kt @@ -1,5 +1,5 @@ // ISSUE: KT-13495 -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.kt b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.kt index 4e7c7fbf94a..005d87ff9f2 100644 --- a/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.kt +++ b/compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.kt @@ -1,5 +1,5 @@ // ISSUE: KT-13495 -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt b/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt index 444fb416c12..ff3c72191d0 100644 --- a/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.fir.kt @@ -1,5 +1,5 @@ // ISSUE: KT-13495 -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // !DIAGNOSTICS: -UNUSED_VARIABLE // FILE: base.kt diff --git a/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt b/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt index fdd2bdcb6a8..c6da20d58a6 100644 --- a/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt +++ b/compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt @@ -1,5 +1,5 @@ // ISSUE: KT-13495 -// !LANGUAGE: +FreedomForSealedClasses +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage // !DIAGNOSTICS: -UNUSED_VARIABLE // FILE: base.kt diff --git a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt index 4587f2142b4..28c559c7734 100644 --- a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.fir.kt @@ -1,5 +1,5 @@ // ISSUE: KT-20423 -// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses +// !LANGUAGE: +SealedInterfaces +AllowSealedInheritorsInDifferentFilesOfSamePackage // MODULE: m1 // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt index 44736417247..b1204703749 100644 --- a/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt +++ b/compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt @@ -1,5 +1,5 @@ // ISSUE: KT-20423 -// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses +// !LANGUAGE: +SealedInterfaces +AllowSealedInheritorsInDifferentFilesOfSamePackage // MODULE: m1 // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.fir.kt b/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.fir.kt index 6ef6ef701ac..d73f4940e35 100644 --- a/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.fir.kt +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.fir.kt @@ -1,5 +1,5 @@ // ISSUE: KT-20423 -// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses +// !LANGUAGE: +SealedInterfaces +AllowSealedInheritorsInDifferentFilesOfSamePackage // MODULE: m1 // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt b/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt index 4074595d4c3..74b6512a36d 100644 --- a/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt @@ -1,5 +1,5 @@ // ISSUE: KT-20423 -// !LANGUAGE: +SealedInterfaces +FreedomForSealedClasses +// !LANGUAGE: +SealedInterfaces +AllowSealedInheritorsInDifferentFilesOfSamePackage // MODULE: m1 // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.kt b/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.kt index 284c4f84434..bb3b9fcbbbb 100644 --- a/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.kt +++ b/compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.kt @@ -1,6 +1,6 @@ // FIR_IDENTICAL // ISSUE: KT-20423 -// !LANGUAGE: +FreedomForSealedClasses +SealedInterfaces +// !LANGUAGE: +AllowSealedInheritorsInDifferentFilesOfSamePackage +SealedInterfaces // !DIAGNOSTICS: -UNUSED_VARIABLE sealed interface Base diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index c72ba064348..296aa35261e 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -695,13 +695,13 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration } fun testSealedClassesAndInterfaces() { - val features = listOf("-XXLanguage:+FreedomForSealedClasses", "-XXLanguage:+SealedInterfaces") + val features = listOf("-XXLanguage:+AllowSealedInheritorsInDifferentFilesOfSamePackage", "-XXLanguage:+SealedInterfaces") val library = compileLibrary("library", additionalOptions = features, checkKotlinOutput = {}) compileKotlin("main.kt", tmpdir, listOf(library), additionalOptions = features) } fun testSealedInheritorInDifferentModule() { - val features = listOf("-XXLanguage:+FreedomForSealedClasses", "-XXLanguage:+SealedInterfaces") + val features = listOf("-XXLanguage:+AllowSealedInheritorsInDifferentFilesOfSamePackage", "-XXLanguage:+SealedInterfaces") val library = compileLibrary("library", additionalOptions = features, checkKotlinOutput = {}) compileKotlin("main.kt", tmpdir, listOf(library), additionalOptions = features) } diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 6b8aff23492..b016571cdcd 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -143,7 +143,7 @@ enum class LanguageFeature( UseCorrectExecutionOrderForVarargArguments(KOTLIN_1_5, kind = BUG_FIX), JvmRecordSupport(KOTLIN_1_5), - FreedomForSealedClasses(KOTLIN_1_5), + AllowSealedInheritorsInDifferentFilesOfSamePackage(KOTLIN_1_5), SealedInterfaces(KOTLIN_1_5), // Temporarily disabled, see KT-27084/KT-22379