From 7e491edf9515d660134b380053a9af0b96c1eeaa Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Tue, 7 Sep 2021 12:17:30 +0300 Subject: [PATCH] Allow empty type info for excl expressions ^KT-34515 Fixed --- .../DiagnosisCompilerTestFE10TestdataTestGenerated.java | 6 ++++++ .../runners/FirOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ ...FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java | 6 ++++++ .../types/expressions/BasicExpressionTypingVisitor.java | 4 +++- .../diagnostics/tests/collectionLiterals/kt34515.fir.kt | 3 +++ .../diagnostics/tests/collectionLiterals/kt34515.kt | 3 +++ .../diagnostics/tests/collectionLiterals/kt34515.txt | 3 +++ .../kotlin/test/runners/DiagnosticTestGenerated.java | 6 ++++++ 8 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt create mode 100644 compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt create mode 100644 compiler/testData/diagnostics/tests/collectionLiterals/kt34515.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 6a019a2ee39..55595365eed 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -4942,6 +4942,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/collectionLiterals/defaultValuesWithConstantsInAnnotation.kt"); } + @Test + @TestMetadata("kt34515.kt") + public void testKt34515() throws Exception { + runTest("compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt"); + } + @Test @TestMetadata("noCollectionLiterals.kt") public void testNoCollectionLiterals() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 5e4d706dede..d0bb117fcfe 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -4942,6 +4942,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/collectionLiterals/defaultValuesWithConstantsInAnnotation.kt"); } + @Test + @TestMetadata("kt34515.kt") + public void testKt34515() throws Exception { + runTest("compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt"); + } + @Test @TestMetadata("noCollectionLiterals.kt") public void testNoCollectionLiterals() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index b96f813c804..77da4ef5824 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -4942,6 +4942,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/collectionLiterals/defaultValuesWithConstantsInAnnotation.kt"); } + @Test + @TestMetadata("kt34515.kt") + public void testKt34515() throws Exception { + runTest("compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt"); + } + @Test @TestMetadata("noCollectionLiterals.kt") public void testNoCollectionLiterals() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index edfe6bd908f..5975d0b25d9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -861,7 +861,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { context.trace.report(diagnosticFactory.on(operationSign)); return baseTypeInfo != null ? baseTypeInfo : components.expressionTypingServices.getTypeInfo(baseExpression, context); } - assert baseTypeInfo != null : "Base expression was not processed: " + expression; + if (baseTypeInfo == null) { + return TypeInfoFactoryKt.noTypeInfo(context); + } KotlinType baseType = baseTypeInfo.getType(); if (baseType == null) { return baseTypeInfo; diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt new file mode 100644 index 00000000000..9c87721a8eb --- /dev/null +++ b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.fir.kt @@ -0,0 +1,3 @@ +fun main() { + []!!!! +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt new file mode 100644 index 00000000000..a303704b115 --- /dev/null +++ b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt @@ -0,0 +1,3 @@ +fun main() { + []!!!! +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.txt b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.txt new file mode 100644 index 00000000000..a9fef69810f --- /dev/null +++ b/compiler/testData/diagnostics/tests/collectionLiterals/kt34515.txt @@ -0,0 +1,3 @@ +package + +public fun main(): kotlin.Unit 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 efc3303bb4a..2954cf663b6 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 @@ -4948,6 +4948,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/collectionLiterals/defaultValuesWithConstantsInAnnotation.kt"); } + @Test + @TestMetadata("kt34515.kt") + public void testKt34515() throws Exception { + runTest("compiler/testData/diagnostics/tests/collectionLiterals/kt34515.kt"); + } + @Test @TestMetadata("noCollectionLiterals.kt") public void testNoCollectionLiterals() throws Exception {