KJS: don't copy members from native interfaces
This commit is contained in:
@@ -3437,6 +3437,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("fromNativeInterface.kt")
|
||||||
|
public void testFromNativeInterface() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/fromNativeInterface.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inheritFromCharIterator.kt")
|
@TestMetadata("inheritFromCharIterator.kt")
|
||||||
public void testInheritFromCharIterator() throws Exception {
|
public void testInheritFromCharIterator() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/inheritFromCharIterator.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inheritance/inheritFromCharIterator.kt");
|
||||||
|
|||||||
+5
-1
@@ -22,6 +22,7 @@ import com.google.dart.compiler.backend.js.ast.JsNameRef
|
|||||||
import org.jetbrains.kotlin.backend.common.bridges.generateBridgesForFunctionDescriptor
|
import org.jetbrains.kotlin.backend.common.bridges.generateBridgesForFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.js.translate.context.StaticContext
|
import org.jetbrains.kotlin.js.translate.context.StaticContext
|
||||||
|
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isNativeObject
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.prototypeOf
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.prototypeOf
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn
|
||||||
@@ -43,6 +44,9 @@ class InterfaceFunctionCopier(val context: StaticContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addInterfaceDefaultMembers(descriptor: ClassDescriptor, context: StaticContext) {
|
private fun addInterfaceDefaultMembers(descriptor: ClassDescriptor, context: StaticContext) {
|
||||||
|
// optimization: don't do anything for native declarations
|
||||||
|
if (isNativeObject(descriptor)) return
|
||||||
|
|
||||||
val classModel = ClassModel(descriptor)
|
val classModel = ClassModel(descriptor)
|
||||||
classModels[descriptor] = classModel
|
classModels[descriptor] = classModel
|
||||||
|
|
||||||
@@ -60,7 +64,7 @@ class InterfaceFunctionCopier(val context: StaticContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val superModels = DescriptorUtils.getSuperclassDescriptors(descriptor)
|
val superModels = DescriptorUtils.getSuperclassDescriptors(descriptor)
|
||||||
.filter { it.kind == ClassKind.INTERFACE }
|
.filter { it.kind == ClassKind.INTERFACE && !isNativeObject(it) }
|
||||||
.map { classModels[it]!! }
|
.map { classModels[it]!! }
|
||||||
for (superModel in superModels) {
|
for (superModel in superModels) {
|
||||||
for (name in superModel.copiedFunctions) {
|
for (name in superModel.copiedFunctions) {
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
@native
|
||||||
|
interface A {
|
||||||
|
val bar: Int get() = noImpl
|
||||||
|
fun foo(): String = noImpl
|
||||||
|
}
|
||||||
|
|
||||||
|
class C : A
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val c = C()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user