FIR: utilize checking subtype of functional type and finding invoke symbol
This commit is contained in:
committed by
Denis Zharkov
parent
b10466f6a2
commit
5b136516c4
+12
-3
@@ -15,12 +15,17 @@ fun builder(c: suspend () -> Unit) {
|
||||
|
||||
suspend fun useSuspendFun(fn : suspend () -> String) = fn()
|
||||
suspend fun useSuspendFunInt(fn: suspend (Int) -> String) = fn(42)
|
||||
suspend fun useSuspendFunStringString(fn: suspend (String, String) -> String) = fn("O", "K")
|
||||
|
||||
class Test : () -> String, (Int) -> String {
|
||||
open class Test : () -> String, (Int) -> String {
|
||||
override fun invoke(): String = "OKEmpty"
|
||||
override fun invoke(p: Int) = "OK$p"
|
||||
}
|
||||
|
||||
class Sub : Test(), (String, String) -> String {
|
||||
override fun invoke(p1: String, p2: String) = p1 + p2
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var test = "Failed"
|
||||
builder {
|
||||
@@ -30,10 +35,14 @@ fun box(): String {
|
||||
if (test != "OKEmpty") return "failed 1"
|
||||
|
||||
builder {
|
||||
test = useSuspendFunInt(Test())
|
||||
test = useSuspendFunInt(Sub())
|
||||
}
|
||||
|
||||
if (test != "OK42") return "failed 2"
|
||||
|
||||
return "OK"
|
||||
builder {
|
||||
test = useSuspendFunStringString(Sub())
|
||||
}
|
||||
|
||||
return test
|
||||
}
|
||||
Reference in New Issue
Block a user