JVM_IR KT-47939 use FunInterfaceConstructorReference as base class

This commit is contained in:
Dmitry Petrov
2021-12-07 17:30:56 +03:00
committed by TeamCityServer
parent 0ccd7a7e0c
commit 93713a9ad4
13 changed files with 158 additions and 42 deletions
@@ -0,0 +1,24 @@
// !LANGUAGE: +KotlinFunInterfaceConstructorReference
// DONT_TARGET_EXACT_BACKEND: JVM
// ^ old JVM BE generates bogus code
// IGNORE_BACKEND: JS
// ^ Failed: kr is class Function1
// WITH_REFLECT
import kotlin.reflect.KFunction
fun interface KRunnable {
fun run()
}
val kr = ::KRunnable // : KFunction1<() -> Unit, KRunnable>
fun box(): String {
return if (kr is KFunction<*>)
"OK"
else
"Failed: kr is ${kr::class}"
}
@@ -0,0 +1,16 @@
// !LANGUAGE: +KotlinFunInterfaceConstructorReference
// IGNORE_BACKEND: JVM
// ^ unsupported in old JVM BE
fun interface KRunnable {
fun run()
}
val kr = ::KRunnable // : KFunction1<() -> Unit, KRunnable>
fun box(): String {
var test = "Failed"
kr { test = "OK" }.run()
return test
}