diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java index 9b1f3825aef..15cee5f7dd5 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFirTestdataTestGenerated.java @@ -3817,6 +3817,12 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt"); } + @Test + @TestMetadata("incompleteWhen.kt") + public void testIncompleteWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt"); + } + @Test @TestMetadata("innerClassHierarchy.kt") public void testInnerClassHierarchy() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java index ef80433a914..59729546ffc 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated.java @@ -3817,6 +3817,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt"); } + @Test + @TestMetadata("incompleteWhen.kt") + public void testIncompleteWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt"); + } + @Test @TestMetadata("innerClassHierarchy.kt") public void testInnerClassHierarchy() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java index 7af38c62cb6..b65e11ca27d 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTestGenerated.java @@ -3356,6 +3356,11 @@ public class LazyBodyIsNotTouchedTestGenerated extends AbstractLazyBodyIsNotTouc runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt"); } + @TestMetadata("incompleteWhen.kt") + public void testIncompleteWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt"); + } + @TestMetadata("innerClassHierarchy.kt") public void testInnerClassHierarchy() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/problems/innerClassHierarchy.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.fir.txt new file mode 100644 index 00000000000..d25b7b0049c --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.fir.txt @@ -0,0 +1,9 @@ +FILE: incompleteWhen.kt + public final fun main(args: R|kotlin/Array|): R|kotlin/Unit| { + lval x: R|kotlin/Int| = Int(42) + when (R|/x|) { + ($subj$ is ) -> { + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt b/compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt new file mode 100644 index 00000000000..308e541f849 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt @@ -0,0 +1,4 @@ +fun main(args: Array) { + val x = 42 + when (x) {is} +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java index cc1c8d18e52..2c66e1f6aa7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeDiagnosticsTestGenerated.java @@ -3817,6 +3817,12 @@ public class FirLightTreeDiagnosticsTestGenerated extends AbstractFirLightTreeDi runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt"); } + @Test + @TestMetadata("incompleteWhen.kt") + public void testIncompleteWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt"); + } + @Test @TestMetadata("innerClassHierarchy.kt") public void testInnerClassHierarchy() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java index b4ff28db701..48dec3f5f80 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiDiagnosticTestGenerated.java @@ -3817,6 +3817,12 @@ public class FirPsiDiagnosticTestGenerated extends AbstractFirPsiDiagnosticTest runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteUserTypeWithUnresovledTypeArgument.kt"); } + @Test + @TestMetadata("incompleteWhen.kt") + public void testIncompleteWhen() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/problems/incompleteWhen.kt"); + } + @Test @TestMetadata("innerClassHierarchy.kt") public void testInnerClassHierarchy() throws Exception { diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 0f0bf6ceae4..166f6fa2be4 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -45,6 +45,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.CallableId import org.jetbrains.kotlin.name.SpecialNames @@ -912,7 +913,7 @@ class ExpressionsConverter( hasSubject: Boolean, ): WhenConditionConvertedResults { lateinit var firOperation: FirOperation - lateinit var firType: FirTypeRef + var firType: FirTypeRef? = null whenCondition.forEachChildren { when (it.tokenType) { TYPE_REFERENCE -> firType = declarationsConverter.convertType(it) @@ -929,7 +930,7 @@ class ExpressionsConverter( val result = buildTypeOperatorCall { source = whenCondition.toFirSourceElement() operation = firOperation - conversionTypeRef = firType + conversionTypeRef = firType ?: buildErrorTypeRef { diagnostic = ConeSyntaxDiagnostic("Incomplete code") } argumentList = buildUnaryArgumentList(subjectExpression) }