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 5db974d7ab7..a6b54dd2470 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 @@ -22962,6 +22962,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt"); } + @Test + @TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt") + public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt"); + } + @Test @TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt") public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt index fd143748cf1..af4e965302c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt @@ -205,10 +205,12 @@ class KotlinToResolvedCallTransformer( ): ResolvedCall { val psiKotlinCall = completedCallAtom.atom.psiKotlinCall return if (psiKotlinCall is PSIKotlinCallForInvoke) { + val diagnosticsForVariableCall = if (completedCallAtom.candidateDescriptor is FunctionDescriptor) emptyList() else diagnostics + val diagnosticsForFunctionCall = if (completedCallAtom.candidateDescriptor is FunctionDescriptor) diagnostics else emptyList() @Suppress("UNCHECKED_CAST") NewVariableAsFunctionResolvedCallImpl( - createOrGet(psiKotlinCall.variableCall.resolvedCall, trace, resultSubstitutor, diagnostics), - createOrGet(completedCallAtom, trace, resultSubstitutor, diagnostics), + createOrGet(psiKotlinCall.variableCall.resolvedCall, trace, resultSubstitutor, diagnosticsForVariableCall), + createOrGet(completedCallAtom, trace, resultSubstitutor, diagnosticsForFunctionCall), ) as ResolvedCall } else { createOrGet(completedCallAtom, trace, resultSubstitutor, diagnostics) diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt index 2ee1eebab8f..45c41ac0bbf 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt @@ -275,7 +275,7 @@ fun poll8() { fun poll81() { val inv = ::bar2 in setOf(::foo2) - inv() + inv() } fun poll82() { diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt b/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt index cdcac34ffd7..aa925573843 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt @@ -7,7 +7,7 @@ fun Int.invoke(a: Int, b: Int) {} class SomeClass fun test(identifier: SomeClass, fn: String.() -> Unit) { - identifier() + identifier() identifier(123) identifier(1, 2) 1.fn() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt new file mode 100644 index 00000000000..742e829b7aa --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt @@ -0,0 +1,16 @@ +object Scope1 { + val someVar: Any = Any() + + fun foo() { + someVar(1) + } +} + +object Scope2 { + class Foo + + fun use() { + val foo = Foo() + foo() + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt new file mode 100644 index 00000000000..b6ef7b7e525 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt @@ -0,0 +1,16 @@ +object Scope1 { + val someVar: Any = Any() + + fun foo() { + someVar(1) + } +} + +object Scope2 { + class Foo + + fun use() { + val foo = Foo() + foo() + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt new file mode 100644 index 00000000000..994753b0225 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt @@ -0,0 +1,25 @@ +package + +public object Scope1 { + private constructor Scope1() + public final val someVar: kotlin.Any + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Scope2 { + private constructor Scope2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public final fun use(): kotlin.Unit + + public final class Foo { + public constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt index fccb7472ec7..ddf18776e96 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt @@ -6,7 +6,7 @@ fun Int.invoke() {} class SomeClass fun test(identifier: SomeClass, fn: String.() -> Unit) { - identifier() + identifier() identifier(123) identifier(1, 2) 1.fn() 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 6a69a0267a1..cc0bb43c59b 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 @@ -22974,6 +22974,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt"); } + @Test + @TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt") + public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt"); + } + @Test @TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt") public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception {