From 54ab3d39db0cdfcf6f6a4e40e834d2d883c22a07 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Tue, 7 Nov 2023 17:43:21 +0100 Subject: [PATCH] [FIR] Fix crash on incorrect call on ILT ^KT-62306 Fixed --- .../DiagnosticCompilerTestFE10TestdataTestGenerated.java | 6 ++++++ ...ReversedDiagnosticCompilerFE10TestDataTestGenerated.java | 6 ++++++ .../FirLightTreeOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../runners/FirPsiOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt | 2 +- .../diagnostics/tests/exceptions/incorrectCallOnILT.kt | 6 ++++++ .../kotlin/test/runners/DiagnosticTestGenerated.java | 6 ++++++ 7 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt 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 1d0b5bbab80..6bdafa1fa56 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 @@ -12300,6 +12300,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt"); } + @Test + @TestMetadata("incorrectCallOnILT.kt") + public void testIncorrectCallOnILT() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt"); + } + @Test @TestMetadata("kt24158.kt") public void testKt24158() 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 e0ad69d0d1f..e53e5ece25f 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 @@ -12300,6 +12300,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt"); } + @Test + @TestMetadata("incorrectCallOnILT.kt") + public void testIncorrectCallOnILT() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt"); + } + @Test @TestMetadata("kt24158.kt") public void testKt24158() 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 8a5a1581645..c8690b3db56 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 @@ -12294,6 +12294,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt"); } + @Test + @TestMetadata("incorrectCallOnILT.kt") + public void testIncorrectCallOnILT() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt"); + } + @Test @TestMetadata("kt24158.kt") public void testKt24158() 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 e71c7ebb487..c6fa9d3443c 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 @@ -12300,6 +12300,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt"); } + @Test + @TestMetadata("incorrectCallOnILT.kt") + public void testIncorrectCallOnILT() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt"); + } + @Test @TestMetadata("kt24158.kt") public void testKt24158() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt index 2c0b6628442..10a372cdb65 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CandidateFactory.kt @@ -125,7 +125,7 @@ class CandidateFactory private constructor( // There is no need to unwrap unary operators if (fir.valueParameters.isEmpty()) return this val original = fir.originalForWrappedIntegerOperator ?: return this - return if (callInfo.arguments.first().isIntegerLiteralOrOperatorCall()) { + return if (callInfo.arguments.firstOrNull()?.isIntegerLiteralOrOperatorCall() == true) { this } else { original diff --git a/compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt b/compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt new file mode 100644 index 00000000000..3ea96476bc3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt @@ -0,0 +1,6 @@ +// FIR_IDENTICAL +// ISSUE: KT-62306 + +fun main() { + 1.plus() +} 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 9376990898f..00048eab6dc 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 @@ -12300,6 +12300,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/exceptions/expectedSomeTypesOnBranchForWhenExpressionOfErroneousType.kt"); } + @Test + @TestMetadata("incorrectCallOnILT.kt") + public void testIncorrectCallOnILT() throws Exception { + runTest("compiler/testData/diagnostics/tests/exceptions/incorrectCallOnILT.kt"); + } + @Test @TestMetadata("kt24158.kt") public void testKt24158() throws Exception {