FIR: initial support of suspend conversion for function reference

This commit is contained in:
Jinseong Jeon
2020-07-24 15:19:28 -07:00
committed by Mikhail Glukhikh
parent b9243aad24
commit 5a3367e09c
21 changed files with 230 additions and 68 deletions
@@ -9,10 +9,10 @@ fun bar2(x: Int) {}
fun bar2(s: String) {}
fun test() {
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar1)
foo1(::bar1)
<!INAPPLICABLE_CANDIDATE!>foo2<!>(42, <!UNRESOLVED_REFERENCE!>::bar2<!>)
<!INAPPLICABLE_CANDIDATE!>foo2<!>("str", <!UNRESOLVED_REFERENCE!>::bar2<!>)
foo2(42, ::bar2)
foo2("str", ::bar2)
<!INAPPLICABLE_CANDIDATE!>foo2<!>(42, ::bar1)
}
@@ -22,7 +22,7 @@ object Test2 {
fun test() {
val result = foo(::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
}
@@ -11,7 +11,7 @@ object Test1 {
fun test() {
val result = foo(::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
}
@@ -29,7 +29,7 @@ object Test2 {
fun test() {
val result = foo(::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Double")!>result<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
}
@@ -20,7 +20,7 @@ fun test(
<!INAPPLICABLE_CANDIDATE!>foo2<!>(f2)
<!INAPPLICABLE_CANDIDATE!>foo3<!>(f3)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar)
foo1(::bar)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f2)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f3)
@@ -1,21 +0,0 @@
// !LANGUAGE: +SuspendConversion
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun interface SuspendRunnable {
suspend fun invoke()
}
fun foo1(s: SuspendRunnable) {}
fun bar1() {}
fun bar2(s: String = ""): Int = 0
fun bar3() {}
suspend fun bar3(s: String = ""): Int = 0
fun test() {
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar1)
<!INAPPLICABLE_CANDIDATE!>foo1<!>(::bar2)
foo1(::bar3) // Should be ambiguity
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +SuspendConversion
// !DIAGNOSTICS: -UNUSED_PARAMETER
@@ -14,8 +14,8 @@ fun unitCoercionAndDefaults(f: suspend () -> Unit) {}
fun all(s: String = ""): Int = 0
fun test() {
<!INAPPLICABLE_CANDIDATE!>unitCoercion<!>(::foo)
<!INAPPLICABLE_CANDIDATE!>defaults<!>(::bar)
unitCoercion(::foo)
defaults(::bar)
<!INAPPLICABLE_CANDIDATE!>varargs<!>(::baz)
<!INAPPLICABLE_CANDIDATE!>unitCoercionAndDefaults<!>(::all)
unitCoercionAndDefaults(::all)
}
@@ -14,5 +14,5 @@ abstract class SubInt : () -> Int
fun test(f: () -> String, s: SubInt) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(f)
<!INAPPLICABLE_CANDIDATE!>foo<!>(s)
<!INAPPLICABLE_CANDIDATE!>foo<!>(::bar)
foo(::bar)
}
@@ -8,7 +8,7 @@ fun bar(): String = ""
abstract class SubInt : () -> Int
fun test(g: () -> Double, s: SubInt) {
<!INAPPLICABLE_CANDIDATE!>foo<!>(::bar)
foo(::bar)
<!INAPPLICABLE_CANDIDATE!>foo<!>(g)
<!INAPPLICABLE_CANDIDATE!>foo<!>(s)
}