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 e0d4ca07cfb..6b86afa4a42 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 @@ -11835,6 +11835,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/inference/equalitySubstitutionInsideNonInvariantType.kt"); } + @Test + @TestMetadata("errorsOnImplicitInvokeInSimpleCall.kt") + public void testErrorsOnImplicitInvokeInSimpleCall() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.kt"); + } + @Test @TestMetadata("expectedTypeAdditionalTest.kt") public void testExpectedTypeAdditionalTest() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 4827e3e4d9a..7398559c52d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -446,8 +446,14 @@ class DiagnosticReporterByTrackingStrategy( if (isDiagnosticRedundant) return val expression = when (val atom = error.resolvedAtom.atom) { - is PSIKotlinCallForInvoke -> (atom.psiCall as? CallTransformer.CallForImplicitInvoke)?.outerCall?.calleeExpression - is PSIKotlinCall -> atom.psiCall.calleeExpression + is PSIKotlinCall -> { + val psiCall = atom.psiCall + if (psiCall is CallTransformer.CallForImplicitInvoke) { + psiCall.outerCall.calleeExpression + } else { + psiCall.calleeExpression + } + } is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression() else -> call.calleeExpression } ?: return diff --git a/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.fir.kt b/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.fir.kt new file mode 100644 index 00000000000..a8ab368233b --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.fir.kt @@ -0,0 +1,4 @@ +inline operator fun Int.invoke() = this + +val a2 = 1() +val a3 = 1.invoke() diff --git a/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.kt b/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.kt new file mode 100644 index 00000000000..58dd705eb14 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.kt @@ -0,0 +1,4 @@ +inline operator fun Int.invoke() = this + +val a2 = 1() +val a3 = 1.invoke() diff --git a/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.txt b/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.txt new file mode 100644 index 00000000000..716eb401e26 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.txt @@ -0,0 +1,5 @@ +package + +public val a2: kotlin.Int +public val a3: kotlin.Int +public inline operator fun kotlin.Int.invoke(): kotlin.Int 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 32e1253c1d5..197f76038e4 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 @@ -11841,6 +11841,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/equalitySubstitutionInsideNonInvariantType.kt"); } + @Test + @TestMetadata("errorsOnImplicitInvokeInSimpleCall.kt") + public void testErrorsOnImplicitInvokeInSimpleCall() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/errorsOnImplicitInvokeInSimpleCall.kt"); + } + @Test @TestMetadata("expectedTypeAdditionalTest.kt") public void testExpectedTypeAdditionalTest() throws Exception {