[KT-24335]

Fix inheritance from interface which is also inherited from an external interface
Add test case
This commit is contained in:
Roman Artemev
2018-05-10 17:11:15 +03:00
committed by Roman Artemev
parent 93f5fe2451
commit 4f2d5baa5d
4 changed files with 42 additions and 1 deletions
@@ -3547,6 +3547,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inheritance/interfaces"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("fromExternalInterface.kt")
public void testFromExternalInterface() throws Exception {
runTest("js/js.translator/testData/box/inheritance/interfaces/fromExternalInterface.kt");
}
@TestMetadata("withDefaultMethod.kt")
public void testWithDefaultMethod() throws Exception {
runTest("js/js.translator/testData/box/inheritance/interfaces/withDefaultMethod.kt");
@@ -3547,6 +3547,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inheritance/interfaces"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS_IR, true);
}
@TestMetadata("fromExternalInterface.kt")
public void testFromExternalInterface() throws Exception {
runTest("js/js.translator/testData/box/inheritance/interfaces/fromExternalInterface.kt");
}
@TestMetadata("withDefaultMethod.kt")
public void testWithDefaultMethod() throws Exception {
runTest("js/js.translator/testData/box/inheritance/interfaces/withDefaultMethod.kt");
@@ -192,7 +192,7 @@ class ClassModelGenerator(val context: TranslationContext) {
if (!visitedDescriptors.add(original) || !original.filter()) return
val overridden = original.getTypedOverriddenDescriptors().map { it.getOriginalDescriptor() }
if (original.kind.isReal) {
if (original.kind.isReal && !original.isEffectivelyExternal()) {
collectedDescriptors.putIfAbsent(original, source)
}
else {
@@ -0,0 +1,31 @@
// EXPECTED_REACHABLE_NODES: 1093
external interface Foo {
var externalProperty: String?
get() = definedExternally
set(it) = definedExternally
}
interface Bar : Foo
class CCC: Foo
class DDD: Bar
interface Bar2: Foo {
override var externalProperty: String?
get() = "Bar2"
set(value) {}
}
class FFF: Bar2
fun box(): String {
val c = CCC()
if (c.externalProperty != null) return "fail1"
val d = DDD()
if (d.externalProperty != null) return "fail2"
val f = FFF()
if (f.externalProperty != "Bar2") return "fail3"
return "OK"
}