[FIR] Handle receiver types of extension methods when computing maximally specific types.
Test case (from testPrimitiveReceiver): fun Short.foo() = 3 fun Int.foo() = 4 1::foo
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
f7dc06a772
commit
a1e0e8b0e7
+3
-3
@@ -6,14 +6,14 @@ fun IB.extFun(x: IA) {}
|
||||
|
||||
fun test() {
|
||||
val extFun1 = IA::extFun
|
||||
val extFun2 = IB::extFun
|
||||
val extFun2 = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
|
||||
}
|
||||
|
||||
fun testWithExpectedType() {
|
||||
// NB: should be resolved to kotlin/FunctionX, not kotlin/reflect/FunctionX
|
||||
val extFun_AB_A: IA.(IB) -> Unit = IA::extFun
|
||||
val extFun_AA_B: IA.(IA) -> Unit = IB::extFun
|
||||
val extFun_AA_B: IA.(IA) -> Unit = <!UNRESOLVED_REFERENCE!>IB::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::extFun
|
||||
val extFun_BB_B: IB.(IB) -> Unit = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
|
||||
}
|
||||
|
||||
+3
-3
@@ -9,12 +9,12 @@ FILE: moreSpecificAmbiguousExtensions.kt
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
lval extFun1: R|kotlin/reflect/KFunction2<IA, IB, kotlin/Unit>| = Q|IA|::R|/extFun|
|
||||
lval extFun2: R|kotlin/reflect/KFunction2<IB, IB, kotlin/Unit>| = Q|IB|::R|/extFun|
|
||||
lval extFun2: <ERROR TYPE REF: No result type for initializer> = Q|IB|::<Unresolved reference: extFun>#
|
||||
}
|
||||
public final fun testWithExpectedType(): R|kotlin/Unit| {
|
||||
lval extFun_AB_A: R|IA.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun|
|
||||
lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::R|/extFun|
|
||||
lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
|
||||
lval extFun_BB_A: R|IB.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun|
|
||||
lval extFun_BA_B: R|IB.(IA) -> kotlin/Unit| = Q|IB|::R|/extFun|
|
||||
lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::R|/extFun|
|
||||
lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
|
||||
}
|
||||
|
||||
+3
-3
@@ -163,9 +163,9 @@ abstract class AbstractConeCallConflictResolver(
|
||||
call: Candidate,
|
||||
function: FirFunction<*>
|
||||
): List<ConeKotlinType> {
|
||||
return (call.resultingTypeForCallableReference?.typeArguments?.map { it as ConeKotlinType }
|
||||
?: (listOfNotNull(function.receiverTypeRef?.coneTypeUnsafe()) +
|
||||
call.argumentMapping?.map { it.value.argumentType() }.orEmpty()))
|
||||
return listOfNotNull(function.receiverTypeRef?.coneTypeUnsafe()) +
|
||||
(call.resultingTypeForCallableReference?.typeArguments?.map { it as ConeKotlinType }
|
||||
?: call.argumentMapping?.map { it.value.argumentType() }.orEmpty())
|
||||
}
|
||||
|
||||
private fun createFlatSignature(call: Candidate, klass: FirClass<*>): FlatSignature<Candidate> {
|
||||
|
||||
Reference in New Issue
Block a user