diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt index 2a79890cc19..478f9301293 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSyntheticCallGenerator.kt @@ -21,6 +21,8 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall import org.jetbrains.kotlin.fir.moduleData import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference +import org.jetbrains.kotlin.fir.references.builder.buildResolvedErrorReference import org.jetbrains.kotlin.fir.references.impl.FirStubReference import org.jetbrains.kotlin.fir.references.isError import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents @@ -196,6 +198,20 @@ class FirSyntheticCallGenerator( (completedCallableReference?.calleeReference as? FirNamedReferenceWithCandidate) ?.toErrorReference(callCalleeReference.diagnostic) ?.let { completedCallableReference.replaceCalleeReference(it) } + + if (!callableReferenceAccess.calleeReference.isError()) { + val resolvedReference = callableReferenceAccess.calleeReference as? FirResolvedCallableReference + ?: error("By this time the actual callable reference must have already been resolved") + + callableReferenceAccess.replaceCalleeReference( + buildResolvedErrorReference { + this.name = resolvedReference.name + this.source = resolvedReference.source + this.resolvedSymbol = resolvedReference.resolvedSymbol + this.diagnostic = callCalleeReference.diagnostic + } + ) + } } return completedCallableReference diff --git a/compiler/testData/diagnostics/tests/callableReference/generic/expectedFunctionType.fir.kt b/compiler/testData/diagnostics/tests/callableReference/generic/expectedFunctionType.fir.kt index 4c5574d96c3..cf1d20db9bc 100644 --- a/compiler/testData/diagnostics/tests/callableReference/generic/expectedFunctionType.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/generic/expectedFunctionType.fir.kt @@ -11,7 +11,7 @@ class A1 { class A2 { fun a2(key: K): V = TODO() - fun test1(): (String) -> Unit = A2()::a2 + fun test1(): (String) -> Unit = A2()::a2 fun test2(): (T3) -> T3 = A2()::a2 } @@ -19,7 +19,7 @@ class A3 { fun a3(key: T): V = TODO() fun test1(): (T) -> Int = this::a3 - fun test2(): (T) -> Unit = A3()::a3 + fun test2(): (T) -> Unit = A3()::a3 fun test3(): (Int) -> String = A3()::a3 fun test4(): (R) -> Unit = this::a3 diff --git a/compiler/testData/diagnostics/tests/callableReference/parsingPriorityOfGenericArgumentsVsLess.fir.kt b/compiler/testData/diagnostics/tests/callableReference/parsingPriorityOfGenericArgumentsVsLess.fir.kt index 9525642a22c..fa65ae7f618 100644 --- a/compiler/testData/diagnostics/tests/callableReference/parsingPriorityOfGenericArgumentsVsLess.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/parsingPriorityOfGenericArgumentsVsLess.fir.kt @@ -5,5 +5,5 @@ class Foo { } fun test() { - Foo::bar < Int > (2 + 2) + Foo::bar < Int > (2 + 2) } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt index 76ce3d37c81..eae164a7465 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.fir.kt @@ -283,7 +283,7 @@ fun poll45(): Flow { fun poll46(): Flow { return flow { - val inv = try { foo7() } finally { ::Foo7 } + val inv = try { foo7() } finally { ::Foo7 } inv } } @@ -381,7 +381,7 @@ fun poll65(): Flow { fun poll66(): Flow { return flow { - val inv = ::Foo7 + val inv = ::Foo7 inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt index d9819355b91..799848a99ba 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.fir.kt @@ -134,7 +134,7 @@ fun poll45(): Flow { fun poll46(): Flow { return flow { - val inv = try { foo7() } finally { ::Foo7 } + val inv = try { foo7() } finally { ::Foo7 } inv } } diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt index 0e667264a73..ff20ee35762 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesUnrestricted.fir.kt @@ -285,7 +285,7 @@ fun poll45(): Flow { fun poll46(): Flow { return flow { - val inv = try { foo7() } finally { ::Foo7 } + val inv = try { foo7() } finally { ::Foo7 } inv } } @@ -383,7 +383,7 @@ fun poll65(): Flow { fun poll66(): Flow { return flow { - val inv = ::Foo7 + val inv = ::Foo7 inv } } diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt index 26e6c6552ad..6d29d8d137e 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.fir.kt @@ -149,7 +149,7 @@ fun poll42() { } fun poll43() { - val inv = try { ::bar4 } finally { ::foo4 } + val inv = try { ::bar4 } finally { ::foo4 } inv() } @@ -164,7 +164,7 @@ fun poll45() { } fun poll46() { - val inv = try { foo7() } finally { ::Foo7 } + val inv = try { foo7() } finally { ::Foo7 } inv } @@ -184,7 +184,7 @@ fun poll52() { } fun poll53() { - val inv = try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 } + val inv = try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 } inv() } @@ -219,7 +219,7 @@ fun poll62() { } fun poll63() { - val inv = ::bar4 + val inv = ::bar4 inv } @@ -234,7 +234,7 @@ fun poll65() { } fun poll66() { - val inv = ::Foo7 + val inv = ::Foo7 inv } diff --git a/compiler/testData/diagnostics/tests/referenceToParameterizedFun.fir.kt b/compiler/testData/diagnostics/tests/referenceToParameterizedFun.fir.kt deleted file mode 100644 index 4764b0f8f24..00000000000 --- a/compiler/testData/diagnostics/tests/referenceToParameterizedFun.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -// ISSUE: KT-59233 - -fun consume(arg: T) {} - -fun box(): String { - val foo = ::consume - return "OK" -} diff --git a/compiler/testData/diagnostics/tests/referenceToParameterizedFun.kt b/compiler/testData/diagnostics/tests/referenceToParameterizedFun.kt index 30841ebcd4b..2130181a325 100644 --- a/compiler/testData/diagnostics/tests/referenceToParameterizedFun.kt +++ b/compiler/testData/diagnostics/tests/referenceToParameterizedFun.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // ISSUE: KT-59233 fun consume(arg: T) {}