[FIR] Check only for visibility modifiers for NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED error
^KT-58033 Fixed
This commit is contained in:
committed by
Space Team
parent
8314812ef9
commit
6544220b3e
+6
@@ -109,6 +109,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
|
|||||||
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
|
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("sealedClassWithPrivateConstructor.kt")
|
||||||
|
public void testSealedClassWithPrivateConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedClassWithPrivateConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sealedTypeAlias.kt")
|
@TestMetadata("sealedTypeAlias.kt")
|
||||||
public void testSealedTypeAlias() throws Exception {
|
public void testSealedTypeAlias() throws Exception {
|
||||||
|
|||||||
+6
@@ -109,6 +109,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
|
|||||||
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
|
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("sealedClassWithPrivateConstructor.kt")
|
||||||
|
public void testSealedClassWithPrivateConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedClassWithPrivateConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sealedTypeAlias.kt")
|
@TestMetadata("sealedTypeAlias.kt")
|
||||||
public void testSealedTypeAlias() throws Exception {
|
public void testSealedTypeAlias() throws Exception {
|
||||||
|
|||||||
+2
-1
@@ -39,7 +39,8 @@ object FirConstructorAllowedChecker : FirConstructorChecker() {
|
|||||||
ClassKind.CLASS -> if (containingClass is FirRegularClass && containingClass.modality == Modality.SEALED) {
|
ClassKind.CLASS -> if (containingClass is FirRegularClass && containingClass.modality == Modality.SEALED) {
|
||||||
val modifierList = source.getModifierList() ?: return
|
val modifierList = source.getModifierList() ?: return
|
||||||
val hasIllegalModifier = modifierList.modifiers.any {
|
val hasIllegalModifier = modifierList.modifiers.any {
|
||||||
it.token != KtTokens.PROTECTED_KEYWORD && it.token != KtTokens.PRIVATE_KEYWORD
|
val token = it.token
|
||||||
|
token in KtTokens.VISIBILITY_MODIFIERS && token != KtTokens.PROTECTED_KEYWORD && token != KtTokens.PRIVATE_KEYWORD
|
||||||
}
|
}
|
||||||
if (hasIllegalModifier) {
|
if (hasIllegalModifier) {
|
||||||
reporter.reportOn(source, FirErrors.NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED, context)
|
reporter.reportOn(source, FirErrors.NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED, context)
|
||||||
|
|||||||
+1
-1
@@ -18,4 +18,4 @@ class SimpleShared : <!SEALED_INHERITOR_IN_DIFFERENT_MODULE, UNRESOLVED_REFERENC
|
|||||||
// TARGET_PLATFORM: JVM
|
// TARGET_PLATFORM: JVM
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
actual sealed class SealedWithPlatformActuals <!ACTUAL_WITHOUT_EXPECT, NON_PRIVATE_OR_PROTECTED_CONSTRUCTOR_IN_SEALED!>actual constructor()<!>: <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedWithSharedActual<!>()
|
actual sealed class SealedWithPlatformActuals <!ACTUAL_WITHOUT_EXPECT!>actual constructor()<!>: <!SEALED_INHERITOR_IN_DIFFERENT_MODULE!>SealedWithSharedActual<!>()
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// ISSUE: KT-58033
|
||||||
|
// MODULE: m1-common
|
||||||
|
// FILE: common.kt
|
||||||
|
|
||||||
|
expect sealed class Frame private constructor()
|
||||||
|
|
||||||
|
// MODULE: m2-jvm()()(m1-common)
|
||||||
|
// FILE: jvm.kt
|
||||||
|
|
||||||
|
actual sealed class Frame actual constructor()
|
||||||
Generated
+6
@@ -21930,6 +21930,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
|
runTest("compiler/testData/diagnostics/tests/multiplatform/privateTopLevelDeclarations.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("sealedClassWithPrivateConstructor.kt")
|
||||||
|
public void testSealedClassWithPrivateConstructor() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/multiplatform/sealedClassWithPrivateConstructor.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sealedTypeAlias.kt")
|
@TestMetadata("sealedTypeAlias.kt")
|
||||||
public void testSealedTypeAlias() throws Exception {
|
public void testSealedTypeAlias() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user