[K/N] Remap type args of SAM interfaces in FunctionReferenceLowering

#KT-56188 Fixed
This commit is contained in:
Sergej Jaskiewicz
2023-01-26 20:40:20 +01:00
committed by Space Team
parent 61fc3e99b1
commit bd18fd40ea
13 changed files with 107 additions and 8 deletions
+28
View File
@@ -0,0 +1,28 @@
// IGNORE_BACKEND: JS
fun interface Supplier<SupplierTP> {
fun get(): SupplierTP
}
fun <FooTP> foo(t: FooTP): Supplier<FooTP> {
return Supplier<FooTP> { t } as Supplier<FooTP>
}
// Let's do some enterprise-style programming shall we
fun interface SupplierInvoker<SupplierInvokerTP1, SupplierInvokerTP2: Supplier<SupplierInvokerTP1>> {
fun invokeSupplier(supplier: SupplierInvokerTP2): SupplierInvokerTP1
}
fun <BarTP1, BarTP2 : Supplier<BarTP1>> bar(): SupplierInvoker<BarTP1, BarTP2> {
return SupplierInvoker<BarTP1, BarTP2> { supplier -> supplier.get() } as SupplierInvoker<BarTP1, BarTP2>
}
fun box(): String {
val result1 = foo("OK").get()
if (result1 != "OK") return result1
val result2 = bar<String, Supplier<String>>().invokeSupplier { "OK" }
if (result2 != "OK") return result2
return "OK"
}