Files
kotlin-fork/compiler/testData/codegen/box/suspendConversion/suspendConversionCompatibility.kt
T
Mikhail Glukhikh a7dc381b93 K2: disable compatibility mode for new inference
#KT-64306 Fixed
#KT-64307 Fixed
#KT-64308 Fixed
2023-12-20 21:39:21 +01:00

56 lines
1.2 KiB
Kotlin
Vendored

// !LANGUAGE: +SuspendConversion
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
// WITH_STDLIB
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, JS_IR_ES6, NATIVE, WASM
// K2 status: java.lang.Integer cannot be cast to java.lang.String (inference changed due to KT-63558)
object Test1 {
fun foo(f: () -> Unit) {}
object Scope {
fun foo(f: suspend () -> Unit) {}
fun test(g: () -> Unit) {
foo(g)
}
}
}
object Test2 {
inline fun <reified T> foo(crossinline f: suspend () -> T): T = 1 as T
fun <T> foo2(f: suspend () -> T): T = 1 as T
suspend fun bar(): Int = 0
object Scope {
fun bar(): String = ""
fun test() {
val result = foo(::bar)
val result2 = foo2(::bar)
}
}
}
object Test3 {
inline fun <reified T> foo(crossinline f: suspend () -> T): T = "" as T
fun <T> foo2(f: suspend () -> T): T = "" as T
suspend fun bar(x: Int = 42): Int = 0
object Scope {
fun bar(x: Int = 42): String = ""
fun test() {
val result = foo(::bar)
val result2 = foo2(::bar)
}
}
}
fun box(): String {
Test1.Scope.test {}
Test2.Scope.test()
Test3.Scope.test()
return "OK"
}