[FIR] Prevent loosing errors for synthetic outer calls
The error occurs when completing the call for the outer synthetic call `ACCEPT_SPECIFIC_TYPE`. The error is saved into the CS of this outer candidate, which leads to its callable reference to be an error reference, but since such calls are not parts of the FIR tree, we never collect such errors. ^Fixed KT-59233
This commit is contained in:
committed by
Space Team
parent
79fce56c95
commit
d13e60aaec
+16
@@ -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
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ class A1 {
|
||||
class A2 {
|
||||
fun <K, V> a2(key: K): V = TODO()
|
||||
|
||||
fun test1(): (String) -> Unit = A2()::a2
|
||||
fun test1(): (String) -> Unit = A2()::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>a2<!>
|
||||
fun <T3> test2(): (T3) -> T3 = A2()::a2
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class A3<T> {
|
||||
fun <V> a3(key: T): V = TODO()
|
||||
|
||||
fun test1(): (T) -> Int = this::a3
|
||||
fun test2(): (T) -> Unit = A3<T>()::a3
|
||||
fun test2(): (T) -> Unit = A3<T>()::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>a3<!>
|
||||
fun test3(): (Int) -> String = A3<Int>()::a3
|
||||
|
||||
fun <R> test4(): (R) -> Unit = this::<!UNRESOLVED_REFERENCE!>a3<!>
|
||||
|
||||
compiler/testData/diagnostics/tests/callableReference/parsingPriorityOfGenericArgumentsVsLess.fir.kt
Vendored
+1
-1
@@ -5,5 +5,5 @@ class Foo {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Foo::bar <!SYNTAX!>< Int ><!> <!SYNTAX!>(2 + 2)<!>
|
||||
Foo::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar<!> <!SYNTAX!>< Int ><!> <!SYNTAX!>(2 + 2)<!>
|
||||
}
|
||||
|
||||
+2
-2
@@ -283,7 +283,7 @@ fun poll45(): Flow<String> {
|
||||
|
||||
fun poll46(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { foo7() } finally { ::Foo7 }
|
||||
val inv = try { foo7() } finally { ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!> }
|
||||
inv
|
||||
}
|
||||
}
|
||||
@@ -381,7 +381,7 @@ fun poll65(): Flow<String> {
|
||||
|
||||
fun poll66(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ::Foo7
|
||||
val inv = ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!>
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -134,7 +134,7 @@ fun poll45(): Flow<String> {
|
||||
|
||||
fun poll46(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { foo7() } finally { ::Foo7 }
|
||||
val inv = try { foo7() } finally { ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!> }
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -285,7 +285,7 @@ fun poll45(): Flow<String> {
|
||||
|
||||
fun poll46(): Flow<String> {
|
||||
return flow {
|
||||
val inv = try { foo7() } finally { ::Foo7 }
|
||||
val inv = try { foo7() } finally { ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!> }
|
||||
inv
|
||||
}
|
||||
}
|
||||
@@ -383,7 +383,7 @@ fun poll65(): Flow<String> {
|
||||
|
||||
fun poll66(): Flow<String> {
|
||||
return flow {
|
||||
val inv = ::Foo7
|
||||
val inv = ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!>
|
||||
inv
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -149,7 +149,7 @@ fun poll42() {
|
||||
}
|
||||
|
||||
fun poll43() {
|
||||
val inv = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>try { ::bar4 } finally { ::foo4 }<!>
|
||||
val inv = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>try { ::bar4 } finally { ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo4<!> }<!>
|
||||
inv<!NO_VALUE_FOR_PARAMETER!>()<!>
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ fun poll45() {
|
||||
}
|
||||
|
||||
fun poll46() {
|
||||
val inv = try { foo7() } finally { ::Foo7 }
|
||||
val inv = try { foo7() } finally { ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!> }
|
||||
inv
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ fun poll52() {
|
||||
}
|
||||
|
||||
fun poll53() {
|
||||
val inv = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::foo4 }<!>
|
||||
val inv = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>try { ::bar4 } catch (e: Exception) { ::foo4 } finally { ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo4<!> }<!>
|
||||
inv<!NO_VALUE_FOR_PARAMETER!>()<!>
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ fun poll62() {
|
||||
}
|
||||
|
||||
fun poll63() {
|
||||
val inv = ::bar4
|
||||
val inv = ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>bar4<!>
|
||||
inv
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ fun poll65() {
|
||||
}
|
||||
|
||||
fun poll66() {
|
||||
val inv = ::Foo7
|
||||
val inv = ::<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo7<!>
|
||||
inv
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// ISSUE: KT-59233
|
||||
|
||||
fun <T> consume(arg: T) {}
|
||||
|
||||
fun box(): String {
|
||||
val foo = ::consume
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-59233
|
||||
|
||||
fun <T> consume(arg: T) {}
|
||||
|
||||
Reference in New Issue
Block a user