KJS: don't overwrite prototype of native classes when inheriting from them
This commit is contained in:
@@ -3455,6 +3455,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nativeNativeKotlin.kt")
|
||||||
|
public void testNativeNativeKotlin() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/nativeNativeKotlin.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("overrideAnyMethods.kt")
|
@TestMetadata("overrideAnyMethods.kt")
|
||||||
public void testOverrideAnyMethods() throws Exception {
|
public void testOverrideAnyMethods() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/overrideAnyMethods.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/overrideAnyMethods.kt");
|
||||||
|
|||||||
@@ -684,8 +684,9 @@ public final class StaticContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addClassPrototypes(@NotNull ClassDescriptor cls, @NotNull Set<ClassDescriptor> visited) {
|
private void addClassPrototypes(@NotNull ClassDescriptor cls, @NotNull Set<ClassDescriptor> visited) {
|
||||||
if (DescriptorUtilsKt.getModule(cls) != currentModule) return;
|
|
||||||
if (!visited.add(cls)) return;
|
if (!visited.add(cls)) return;
|
||||||
|
if (DescriptorUtilsKt.getModule(cls) != currentModule) return;
|
||||||
|
if (isNativeObject(cls) || isLibraryObject(cls)) return;
|
||||||
|
|
||||||
ClassDescriptor superclass = DescriptorUtilsKt.getSuperClassNotAny(cls);
|
ClassDescriptor superclass = DescriptorUtilsKt.getSuperClassNotAny(cls);
|
||||||
if (superclass != null) {
|
if (superclass != null) {
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// FILE: nativeNativeKotlin.kt
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
@native
|
||||||
|
open class A {
|
||||||
|
fun foo(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
@native
|
||||||
|
open class B : A() {
|
||||||
|
fun bar(): String
|
||||||
|
}
|
||||||
|
|
||||||
|
class C : B()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val c = C()
|
||||||
|
|
||||||
|
assertEquals("A.foo", c.foo())
|
||||||
|
assertEquals("B.bar", c.bar())
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: nativeNativeKotlin.js
|
||||||
|
|
||||||
|
function A() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
A.prototype.foo = function () {
|
||||||
|
return "A.foo"
|
||||||
|
};
|
||||||
|
|
||||||
|
function B() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
B.prototype = Object.create(A.prototype);
|
||||||
|
B.prototype.constructor = B;
|
||||||
|
|
||||||
|
B.prototype.bar = function () {
|
||||||
|
return "B.bar"
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user