[FIR] Fix incorrect resolve of callable reference in function signature (^KT-48304 Fixed)

This commit is contained in:
Ivan Kochurkin
2021-08-19 13:11:47 +03:00
committed by Space
parent 5ddf0cc7b2
commit bb27ae2b42
16 changed files with 95 additions and 23 deletions
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun a() {
val x = 10
<!INAPPLICABLE_CANDIDATE!>foo<!>(::<!UNSUPPORTED!>x<!>)
}
fun foo(a: Any) {}
fun test1(test2: () -> Unit = ::test2) {} // Resolve to function
private fun test2() {}
fun test3(test4: () -> Unit = ::<!UNSUPPORTED!>test4<!>) {}
fun test5(test6: (test: Test) -> Unit = Test::helper) {
test6(Test())
}
class Test {
fun helper() {}
}
@@ -1,9 +1,22 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun a() {
val x = 10
foo(::<!UNSUPPORTED!>x<!>)
}
fun foo(a: Any) {}
fun test1(test2: () -> Unit = ::test2) {} // Resolve to function
private fun test2() {}
fun test3(test4: () -> Unit = ::<!UNSUPPORTED!>test4<!>) {}
fun test5(test6: (test: Test) -> Unit = Test::helper) {
test6(Test())
}
class Test {
fun helper() {}
}
@@ -2,3 +2,16 @@ package
public fun a(): kotlin.Unit
public fun foo(/*0*/ a: kotlin.Any): kotlin.Unit
public fun test1(/*0*/ test2: () -> kotlin.Unit = ...): kotlin.Unit
private fun test2(): kotlin.Unit
public fun test3(/*0*/ test4: () -> kotlin.Unit = ...): kotlin.Unit
public fun test5(/*0*/ test6: (test: Test) -> kotlin.Unit = ...): kotlin.Unit
public final class Test {
public constructor Test()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun helper(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun eat(value: Any) {}
fun test(param: String) {
val a = ::<!UNSUPPORTED!>param<!>
val local = "local"
val b = ::<!UNSUPPORTED!>local<!>
val lambda = { -> }
val g = ::<!UNSUPPORTED!>lambda<!>
<!INAPPLICABLE_CANDIDATE!>eat<!>(::<!UNSUPPORTED!>param<!>)
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
fun eat(value: Any) {}
@@ -9,6 +9,6 @@ class Foo {
fun main() {
val f = Foo()
val a: Int
<!VARIABLE_EXPECTED!>get()<!> = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
<!VARIABLE_EXPECTED!>get()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
}
@@ -9,6 +9,6 @@ class Foo {
fun main(x: Int) {
val f = Foo()
val a: Int
<!VARIABLE_EXPECTED!>get()<!> = f.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
<!VARIABLE_EXPECTED!>get()<!> = f.<!INAPPLICABLE_CANDIDATE!>getValue<!>(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
}