Add test to preserve behaviour
It's important to have ambiguity in these cases to introduce overload resolution by suspend-modifier without breaking changes in future Relates to #KT-23610
This commit is contained in:
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(x: () -> Int) {}
|
||||
fun foo(x: suspend () -> Int) {}
|
||||
|
||||
fun usualCall(): Int = 42
|
||||
suspend fun suspendCall(): Int = 42
|
||||
|
||||
// it's important to have ambiguity in these cases to introduce overload resolution by suspend modifier in future
|
||||
fun test1() {
|
||||
<!AMBIGUITY!>foo<!> { usualCall() }
|
||||
<!AMBIGUITY!>foo<!> { suspendCall() }
|
||||
}
|
||||
|
||||
// candidate without suspend conversions is more specific
|
||||
fun test2(f: () -> Int, g: suspend () -> Int) {
|
||||
foo(f)
|
||||
foo(g)
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(x: () -> Int) {}
|
||||
fun foo(x: suspend () -> Int) {}
|
||||
|
||||
fun usualCall(): Int = 42
|
||||
suspend fun suspendCall(): Int = 42
|
||||
|
||||
// it's important to have ambiguity in these cases to introduce overload resolution by suspend modifier in future
|
||||
fun test1() {
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { usualCall() }
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> { <!ILLEGAL_SUSPEND_FUNCTION_CALL!>suspendCall<!>() }
|
||||
}
|
||||
|
||||
// candidate without suspend conversions is more specific
|
||||
fun test2(f: () -> Int, g: suspend () -> Int) {
|
||||
foo(f)
|
||||
foo(g)
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ x: () -> kotlin.Int): kotlin.Unit
|
||||
public fun foo(/*0*/ x: suspend () -> kotlin.Int): kotlin.Unit
|
||||
public suspend fun suspendCall(): kotlin.Int
|
||||
public fun test1(): kotlin.Unit
|
||||
public fun test2(/*0*/ f: () -> kotlin.Int, /*1*/ g: suspend () -> kotlin.Int): kotlin.Unit
|
||||
public fun usualCall(): kotlin.Int
|
||||
Reference in New Issue
Block a user