[FIR] If callable reference can't be resolved with expected type, try resolving with Any
In positions outside of calls (e.g. property initializers) we resolve callable references using a synthetic outer call with the expected type as parameter type. If this fails, we previously returned an unresolved reference. After this commit, we additionally try to resolve the callable reference with expected type Any. This lets us report more precise diagnostics like type mismatches or when multiple overloads exist NONE_APPLICABLE. #KT-55373 Fixed #KT-55955 Fixed
This commit is contained in:
committed by
Space Team
parent
2c91ae1129
commit
ade1354a84
-9
@@ -1,9 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
val x1 = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
val x2: () -> Unit = ::foo
|
||||
val x3: (String) -> Unit = ::foo
|
||||
val x4: (Int) -> Unit = ::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
|
||||
compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt
Vendored
-21
@@ -1,21 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
interface IA
|
||||
interface IB : IA
|
||||
|
||||
fun IA.extFun(x: IB) {}
|
||||
fun IB.extFun(x: IA) {}
|
||||
|
||||
fun test() {
|
||||
val extFun1 = IA::extFun
|
||||
val extFun2 = IB::<!OVERLOAD_RESOLUTION_AMBIGUITY!>extFun<!>
|
||||
}
|
||||
|
||||
fun testWithExpectedType() {
|
||||
val extFun_AB_A: IA.(IB) -> Unit = IA::extFun
|
||||
val extFun_AA_B: IA.(IA) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun_BB_A: IB.(IB) -> Unit = IA::extFun
|
||||
val extFun_BA_B: IB.(IA) -> Unit = IB::extFun
|
||||
val extFun_BB_B: IB.(IB) -> Unit = IB::<!OVERLOAD_RESOLUTION_AMBIGUITY!>extFun<!>
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user