[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
@@ -47119,6 +47119,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/sam/kt54600.kt");
}
@Test
@TestMetadata("kt56188.kt")
public void testKt56188() throws Exception {
runTest("compiler/testData/codegen/box/sam/kt56188.kt");
}
@Test
@TestMetadata("nonInlinedSamWrapper.kt")
public void testNonInlinedSamWrapper() throws Exception {
+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"
}
@@ -45133,6 +45133,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/sam/kt54600.kt");
}
@Test
@TestMetadata("kt56188.kt")
public void testKt56188() throws Exception {
runTest("compiler/testData/codegen/box/sam/kt56188.kt");
}
@Test
@TestMetadata("nonInlinedSamWrapper.kt")
public void testNonInlinedSamWrapper() throws Exception {
@@ -47119,6 +47119,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/sam/kt54600.kt");
}
@Test
@TestMetadata("kt56188.kt")
public void testKt56188() throws Exception {
runTest("compiler/testData/codegen/box/sam/kt56188.kt");
}
@Test
@TestMetadata("nonInlinedSamWrapper.kt")
public void testNonInlinedSamWrapper() throws Exception {
@@ -36416,6 +36416,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/sam/kt54600.kt");
}
@TestMetadata("kt56188.kt")
public void testKt56188() throws Exception {
runTest("compiler/testData/codegen/box/sam/kt56188.kt");
}
@TestMetadata("nonInlinedSamWrapper.kt")
public void testNonInlinedSamWrapper() throws Exception {
runTest("compiler/testData/codegen/box/sam/nonInlinedSamWrapper.kt");