FIR checker: fix REFERENCE_BY_QUALIFIED positioning strategy to consider callable reference

This commit is contained in:
Jinseong Jeon
2021-03-24 23:26:15 -07:00
committed by Mikhail Glukhikh
parent 8d8ed4cc18
commit bfc7eb7bab
116 changed files with 272 additions and 455 deletions
@@ -16,14 +16,14 @@ fun <T> bar(s: T) {}
fun <T> complex(t: T, f: (T) -> Unit) {}
fun test1() {
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, <!UNRESOLVED_REFERENCE!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
<!INAPPLICABLE_CANDIDATE!>foo<!>(1, A::<!UNRESOLVED_REFERENCE!>invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
foo(1, ::bar)
complex(1, ::bar)
}
fun <R> test2(x: R) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(x, <!UNRESOLVED_REFERENCE!>A::invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
<!INAPPLICABLE_CANDIDATE!>foo<!>(x, A::<!UNRESOLVED_REFERENCE!>invokeLater<!>) // KT-24507 SAM conversion accidentally applied to callable reference and incorrectly handled via BE
foo(x, ::bar)
complex(x, ::bar)
@@ -14,7 +14,7 @@ fun <T> Wrapper<T>.baz(transform: (T) -> Unit): T = TODO()
fun test() {
takeFun<String>(::foo)
<!INAPPLICABLE_CANDIDATE!>takeFun<!><String>(<!UNRESOLVED_REFERENCE!>::fooInt<!>)
<!INAPPLICABLE_CANDIDATE!>takeFun<!><String>(::<!UNRESOLVED_REFERENCE!>fooInt<!>)
callFun<String, Wrapper<String>>(::createWrapper)
callFun<Int, Wrapper<Number>>(::createWrapper)
@@ -23,8 +23,8 @@ fun test1() {
fun <T> test2() {
bar<Wrapper, Int, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, Int, String>>() }
bar<Wrapper, T, String>(Wrapper::fooReturnString).checkType { _<Tripple<Wrapper, T, String>>() }
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, T, T>(<!UNRESOLVED_REFERENCE!>Wrapper::fooReturnString<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, Int, Int>(<!UNRESOLVED_REFERENCE!>Wrapper::fooReturnString<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, T, T>(Wrapper::<!UNRESOLVED_REFERENCE!>fooReturnString<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!><Wrapper, Int, Int>(Wrapper::<!UNRESOLVED_REFERENCE!>fooReturnString<!>)
bar<Wrapper, Int, T>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, T>>() }
bar<Wrapper, Int, String>(Wrapper::fooTakeInt).checkType { _<Tripple<Wrapper, Int, String>>() }
@@ -6,5 +6,5 @@ object TestCallableReferences {
fun test0(): (String) -> String = TestCallableReferences::foo
fun <T> test1(): (List<T>) -> List<T> = <!UNRESOLVED_REFERENCE!>TestCallableReferences::foo<!>
fun <T> test1(): (List<T>) -> List<T> = TestCallableReferences::<!UNRESOLVED_REFERENCE!>foo<!>
}
@@ -11,7 +11,7 @@ fun test() {
val x2: (Int) -> Unit = baz(id(::foo), ::foo)
val x3: (Int) -> Unit = baz(id(::foo), id(id(::foo)))
val x4: (String) -> Unit = baz(id(::foo), id(id(::foo)))
val x5: (Double) -> Unit = baz(id(<!UNRESOLVED_REFERENCE!>::foo<!>), id(id(<!UNRESOLVED_REFERENCE!>::foo<!>)))
val x5: (Double) -> Unit = baz(id(::<!UNRESOLVED_REFERENCE!>foo<!>), id(id(::<!UNRESOLVED_REFERENCE!>foo<!>)))
id<(Int) -> Unit>(id(id(::foo)))
@@ -17,7 +17,7 @@ fun test1() {
baz<String>(::foo).checkType { _<String?>() }
baz<Boolean>(::foo).checkType { _<Boolean?>() }
val b1: Int = baz(<!UNRESOLVED_REFERENCE!>::foo<!>)
val b2: String = baz(<!UNRESOLVED_REFERENCE!>::foo<!>)
val b3: Boolean = baz(<!UNRESOLVED_REFERENCE!>::foo<!>)
val b1: Int = baz(::<!UNRESOLVED_REFERENCE!>foo<!>)
val b2: String = baz(::<!UNRESOLVED_REFERENCE!>foo<!>)
val b3: Boolean = baz(::<!UNRESOLVED_REFERENCE!>foo<!>)
}
@@ -5,9 +5,9 @@ fun test() {
val a1: Array<Double.(Double) -> Double> = arrayOf(Double::plus, Double::minus)
val a2: Array<Double.(Int) -> Double> = arrayOf(Double::plus, Double::minus)
val a3: Array<Int.(Int) -> Double> = arrayOf(<!UNRESOLVED_REFERENCE!>Double::plus<!>, <!UNRESOLVED_REFERENCE!>Double::minus<!>)
val a4: Array<Int.(Double) -> Double> = arrayOf(Int::plus, <!UNRESOLVED_REFERENCE!>Double::minus<!>)
val a5: Array<Double.(Double) -> Double> = arrayOf(Double::plus, <!UNRESOLVED_REFERENCE!>Int::minus<!>)
val a3: Array<Int.(Int) -> Double> = arrayOf(Double::<!UNRESOLVED_REFERENCE!>plus<!>, Double::<!UNRESOLVED_REFERENCE!>minus<!>)
val a4: Array<Int.(Double) -> Double> = arrayOf(Int::plus, Double::<!UNRESOLVED_REFERENCE!>minus<!>)
val a5: Array<Double.(Double) -> Double> = arrayOf(Double::plus, Int::<!UNRESOLVED_REFERENCE!>minus<!>)
}
fun foo(x: Int) {}
@@ -18,5 +18,5 @@ fun <T> bar(x: T, f: (T) -> Unit) {}
fun test2() {
bar(1, ::foo)
bar("", ::foo)
<!INAPPLICABLE_CANDIDATE!>bar<!>(1.0, <!UNRESOLVED_REFERENCE!>::foo<!>)
<!INAPPLICABLE_CANDIDATE!>bar<!>(1.0, ::<!UNRESOLVED_REFERENCE!>foo<!>)
}