K2: Support callable references adaptation on top-level

^KT-45989 In progress
^KT-54709 Related
^KT-55217 Fixed
This commit is contained in:
Denis.Zharkov
2022-11-25 12:28:18 +01:00
committed by Space Team
parent 8f8ea8c57f
commit dcdc48a233
13 changed files with 118 additions and 31 deletions
@@ -0,0 +1,10 @@
// SKIP_TXT
fun baz(options: String = ""): String = ""
fun runForString(x: () -> String) {}
fun foo(dumpStrategy: String) {
val dump0: () -> String = ::baz
runForString(::baz)
}
@@ -0,0 +1,10 @@
// SKIP_TXT
fun baz(options: String = ""): String = ""
fun runForString(x: () -> String) {}
fun foo(dumpStrategy: String) {
val dump0: () -> String = <!TYPE_MISMATCH!>::<!TYPE_MISMATCH!>baz<!><!>
runForString(::baz)
}
@@ -5,5 +5,5 @@ fun foo(x: Any, y: Int) = y
fun main() {
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
val fooRef: (Int, Any) -> Unit = ::<!UNRESOLVED_REFERENCE!>foo<!>
val fooRef: (Int, Any) -> Unit = ::foo
}
@@ -6,5 +6,5 @@ fun foo(i: Int) {}
val fn1: (Int) -> Unit = ::foo
val fn2: (IntArray) -> Unit = ::foo
val fn3: (Int, Int) -> Unit = ::<!UNRESOLVED_REFERENCE!>foo<!>
val fn3: (Int, Int) -> Unit = ::foo
val fn4: (Array<String>) -> Unit = ::foo
@@ -4,8 +4,7 @@
fun main(b: Boolean) {
callWithLambda {
// The only relevant case for KT-55729, Unit conversion should work, but doesn't in K1 1.8.0
// For K2, it still doesn't work (see KT-55936)
::<!UNRESOLVED_REFERENCE!>test1<!>
::test1
}
callWithLambda {
@@ -23,8 +22,8 @@ fun main(b: Boolean) {
}
callWithLambda {
// That hasn't been working ever in K1 nor K2
(::<!UNRESOLVED_REFERENCE!>test1<!>)
// Doesn't work in K1, but does in K2
(::test1)
}
}
@@ -4,7 +4,6 @@
fun main(b: Boolean) {
callWithLambda {
// The only relevant case for KT-55729, Unit conversion should work, but doesn't in K1 1.8.0
// For K2, it still doesn't work (see KT-55936)
::test1
}
@@ -23,7 +22,7 @@ fun main(b: Boolean) {
}
callWithLambda {
// That hasn't been working ever in K1 nor K2
// Doesn't work in K1, but does in K2
(<!TYPE_MISMATCH, TYPE_MISMATCH!>::<!TYPE_MISMATCH!>test1<!><!>)
}
}