[FIR] Don't report MUST_BE_INITIALIZED on private open properites
^KT-59074 Fixed This solution is not ideal. Ideally, the allopen compiler plugin shouldn't report `private` properites as `open` KT-64980, but it will unpredictably break other things.
This commit is contained in:
+6
@@ -3578,6 +3578,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/MustBeInitializedEffectivelyFinalOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenPrivateValDeferredInit.kt")
|
||||
public void testOpenPrivateValDeferredInit() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/OpenPrivateValDeferredInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal.kt")
|
||||
public void testOpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal() throws Exception {
|
||||
|
||||
+6
@@ -3578,6 +3578,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/MustBeInitializedEffectivelyFinalOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenPrivateValDeferredInit.kt")
|
||||
public void testOpenPrivateValDeferredInit() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/OpenPrivateValDeferredInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal.kt")
|
||||
public void testOpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal() throws Exception {
|
||||
|
||||
+6
@@ -3572,6 +3572,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/MustBeInitializedEffectivelyFinalOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenPrivateValDeferredInit.kt")
|
||||
public void testOpenPrivateValDeferredInit() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/OpenPrivateValDeferredInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal.kt")
|
||||
public void testOpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal() throws Exception {
|
||||
|
||||
+6
@@ -3578,6 +3578,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/MustBeInitializedEffectivelyFinalOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenPrivateValDeferredInit.kt")
|
||||
public void testOpenPrivateValDeferredInit() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/OpenPrivateValDeferredInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal.kt")
|
||||
public void testOpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal() throws Exception {
|
||||
|
||||
+3
-1
@@ -149,7 +149,9 @@ internal fun checkPropertyInitializer(
|
||||
val isExternal = property.isEffectivelyExternal(containingClass, context)
|
||||
val isCorrectlyInitialized =
|
||||
property.initializer != null || isDefinitelyAssigned && !property.hasSetterAccessorImplementation &&
|
||||
property.getEffectiveModality(containingClass, context.languageVersionSettings) != Modality.OPEN
|
||||
(property.getEffectiveModality(containingClass, context.languageVersionSettings) != Modality.OPEN ||
|
||||
// Drop this workaround after KT-64980 is fixed
|
||||
property.effectiveVisibility == org.jetbrains.kotlin.descriptors.EffectiveVisibility.PrivateInClass)
|
||||
if (
|
||||
backingFieldRequired &&
|
||||
!inInterface &&
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// LANGUAGE:+ProhibitOpenValDeferredInitialization
|
||||
open class Foo {
|
||||
<!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>open<!> val foo: Int
|
||||
|
||||
init {
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// LANGUAGE:+ProhibitOpenValDeferredInitialization
|
||||
open class Foo {
|
||||
<!MUST_BE_INITIALIZED_OR_FINAL_OR_ABSTRACT!><!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>open<!> val foo: Int<!>
|
||||
|
||||
init {
|
||||
foo = 1
|
||||
}
|
||||
}
|
||||
Generated
+6
@@ -3578,6 +3578,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/MustBeInitializedEffectivelyFinalOn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenPrivateValDeferredInit.kt")
|
||||
public void testOpenPrivateValDeferredInit() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/backingField/OpenPrivateValDeferredInit.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("OpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal.kt")
|
||||
public void testOpenValDeferredInitError_InFinalClass_DisableEffectivelyFinal() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user