diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 83023bab8c2..37c11ff0e21 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -3026,6 +3026,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/backingField/ValDeferredInitInOpenClassOpenValWarning.kt"); } + @Test + @TestMetadata("ValWithSetterDeferredInit.kt") + public void testValWithSetterDeferredInit() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt"); + } + @Test @TestMetadata("VarDeferredInitInFinalClass.kt") public void testVarDeferredInitInFinalClass() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index be931873b64..b4df0ff4986 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -3026,6 +3026,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/backingField/ValDeferredInitInOpenClassOpenValWarning.kt"); } + @Test + @TestMetadata("ValWithSetterDeferredInit.kt") + public void testValWithSetterDeferredInit() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt"); + } + @Test @TestMetadata("VarDeferredInitInFinalClass.kt") public void testVarDeferredInitInFinalClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 8025ac4125e..aa821efd015 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -3026,6 +3026,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/backingField/ValDeferredInitInOpenClassOpenValWarning.kt"); } + @Test + @TestMetadata("ValWithSetterDeferredInit.kt") + public void testValWithSetterDeferredInit() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt"); + } + @Test @TestMetadata("VarDeferredInitInFinalClass.kt") public void testVarDeferredInitInFinalClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index a5bc56fdd3d..3d968e30d7c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -3032,6 +3032,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/backingField/ValDeferredInitInOpenClassOpenValWarning.kt"); } + @Test + @TestMetadata("ValWithSetterDeferredInit.kt") + public void testValWithSetterDeferredInit() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt"); + } + @Test @TestMetadata("VarDeferredInitInFinalClass.kt") public void testVarDeferredInitInFinalClass() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt index d612ba1f7ba..80ccbcbd7c9 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirTopLevelPropertiesChecker.kt @@ -201,9 +201,6 @@ private fun reportMustBeInitialized( suggestMakingItAbstract -> FirErrors.MUST_BE_INITIALIZED_OR_BE_ABSTRACT else -> FirErrors.MUST_BE_INITIALIZED } - if (isOpenValDeferredInitDeprecationWarning && factory == FirErrors.MUST_BE_INITIALIZED) { - error("Not reachable case. We can always suggest making `open val` property `final`") - } reporter.reportOn( propertySource, when (isMissedMustBeInitializedDeprecationWarning || isOpenValDeferredInitDeprecationWarning) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index 0336599ffe8..fcf548dec98 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -841,9 +841,6 @@ class DeclarationsChecker( suggestMakingItAbstract -> MUST_BE_INITIALIZED_OR_BE_ABSTRACT else -> MUST_BE_INITIALIZED } - if (isOpenValDeferredInitDeprecationWarning && factory == MUST_BE_INITIALIZED) { - error("Not reachable case. We can always suggest making `open val` property `final`") - } trace.report( when (isMissedMustBeInitializedDeprecationWarning || isOpenValDeferredInitDeprecationWarning) { true -> factory.deprecationWarning diff --git a/compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt b/compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt new file mode 100644 index 00000000000..849f9a2f445 --- /dev/null +++ b/compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt @@ -0,0 +1,11 @@ +// FIR_IDENTICAL +// LANGUAGE: -ProhibitOpenValDeferredInitialization +// DIAGNOSTICS: -DEBUG_INFO_LEAKING_THIS +open class A { + open val c: Int + set(value) {} + + init { + c = 1 + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index effa1b49dd0..832783c9615 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -3032,6 +3032,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/backingField/ValDeferredInitInOpenClassOpenValWarning.kt"); } + @Test + @TestMetadata("ValWithSetterDeferredInit.kt") + public void testValWithSetterDeferredInit() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/ValWithSetterDeferredInit.kt"); + } + @Test @TestMetadata("VarDeferredInitInFinalClass.kt") public void testVarDeferredInitInFinalClass() throws Exception {