[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:
Juan Chen
2020-04-13 15:35:08 -07:00
committed by Dmitriy Novozhilov
parent f7dc06a772
commit a1e0e8b0e7
10 changed files with 15 additions and 41 deletions
@@ -1,15 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
open class A
class B: A()
fun A.foo() {}
fun B.foo() {} // more specific
fun bar(a: Any) {}
fun bar(a: Int) {} // more specific
fun test() {
<!UNRESOLVED_REFERENCE!>B::foo<!>
::bar
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
open class A
@@ -9,13 +9,13 @@ fun IB.extFun(x: IA) {}
fun test() {
val extFun1 = IA::extFun
val extFun2 = IB::extFun
val extFun2 = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
}
fun testWithExpectedType() {
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<!>
}
@@ -1,12 +0,0 @@
// !CHECK_TYPE
interface IA
interface IB : IA
fun IA.extFun() {}
fun IB.extFun() {}
fun test() {
val extFun = <!UNRESOLVED_REFERENCE!>IB::extFun<!>
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><IB.() -> Unit>(extFun)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !CHECK_TYPE
interface IA
@@ -20,7 +20,7 @@ fun fas() {}
fun fas(i: Int = 1) {}
fun test() {
<!UNRESOLVED_REFERENCE!>B::foo<!> // todo KT-9601 Chose maximally specific function in callable reference
B::foo // todo KT-9601 Chose maximally specific function in callable reference
B::bar checkType { _<KFunction1<B, Unit>>() }