Fix copying of non-abstract functions of interfaces in JS BE

Fix copying of non-abstract functions of interfaces to implementing
classes when implementing class inherits interface via 2+ paths.

See KT-18187
This commit is contained in:
Alexey Andreev
2017-05-30 17:17:40 +03:00
parent c558e2657b
commit e6b0cc64bd
7 changed files with 73 additions and 12 deletions
@@ -0,0 +1,29 @@
interface I {
fun foo(): String = "foo"
fun bar(x: String = "default") = "bar:$x"
}
interface J : I
interface K : J
class A : I, J
class B : K, I
fun box(): String {
val foo = A().foo()
if (foo != "foo") return "fail1: $foo"
val bar1 = A().bar()
if (bar1 != "bar:default") return "fail2: $bar1"
val bar2 = A().bar("q")
if (bar2 != "bar:q") return "fail3: $bar1"
val foo2 = B().foo()
if (foo2 != "foo") return "fail4: $foo2"
return "OK"
}
-3
View File
@@ -1,6 +1,3 @@
// TODO: muted automatically, investigate should it be ran for JS or not
// IGNORE_BACKEND: JS
interface BK {
fun foo(): String = 10.toString()
}
@@ -18044,6 +18044,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("interfaceWithNonAbstractFunIndirect.kt")
public void testInterfaceWithNonAbstractFunIndirect() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/traits/interfaceWithNonAbstractFunIndirect.kt");
doTest(fileName);
}
@TestMetadata("kt1936.kt")
public void testKt1936() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/traits/kt1936.kt");
@@ -18044,6 +18044,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("interfaceWithNonAbstractFunIndirect.kt")
public void testInterfaceWithNonAbstractFunIndirect() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/traits/interfaceWithNonAbstractFunIndirect.kt");
doTest(fileName);
}
@TestMetadata("kt1936.kt")
public void testKt1936() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/traits/kt1936.kt");
@@ -18044,6 +18044,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("interfaceWithNonAbstractFunIndirect.kt")
public void testInterfaceWithNonAbstractFunIndirect() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/traits/interfaceWithNonAbstractFunIndirect.kt");
doTest(fileName);
}
@TestMetadata("kt1936.kt")
public void testKt1936() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/traits/kt1936.kt");