Fix translation of delegated functions with default params in JS BE
See KT-17285
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
var log = ""
|
||||
fun log(a: String) {
|
||||
log += a + ";"
|
||||
}
|
||||
|
||||
interface C {
|
||||
fun foo(x: Int): Unit {
|
||||
log("C.foo($x)")
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
fun foo(x: Int = 1): Unit
|
||||
}
|
||||
|
||||
class G(c: C) : C by c, I
|
||||
class H(c: C) : I, C by c
|
||||
|
||||
fun test1() {
|
||||
log = ""
|
||||
|
||||
val g1 = G(object: C {})
|
||||
g1.foo(2)
|
||||
g1.foo()
|
||||
val g2 = G(object: C {
|
||||
override fun foo(x: Int) {
|
||||
log("[2] object:C.foo($x)")
|
||||
}
|
||||
})
|
||||
g2.foo(2)
|
||||
g2.foo()
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
log = ""
|
||||
|
||||
val h1 = H(object: C {})
|
||||
h1.foo(2)
|
||||
h1.foo()
|
||||
val h2 = H(object: C {
|
||||
override fun foo(x: Int) {
|
||||
log("[2] object:C.foo($x)")
|
||||
}
|
||||
})
|
||||
h2.foo(2)
|
||||
h2.foo()
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
test1()
|
||||
if (log != "C.foo(2);C.foo(1);[2] object:C.foo(2);[2] object:C.foo(1);") return "fail1: $log"
|
||||
|
||||
test2()
|
||||
if (log != "C.foo(2);C.foo(1);[2] object:C.foo(2);[2] object:C.foo(1);") return "fail2: $log"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+12
@@ -7075,6 +7075,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegation/kt8154.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/destructuringDeclInLambdaParam")
|
||||
|
||||
@@ -7075,6 +7075,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegation/kt8154.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void testWithDefaultParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/destructuringDeclInLambdaParam")
|
||||
|
||||
@@ -7048,6 +7048,18 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Delegation extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("withDefaultParameters.kt")
|
||||
public void ignoreWithDefaultParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegation/withDefaultParameters.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDelegation() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/delegation"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user