KJS: fix inheritance from renamed native classes
This commit is contained in:
@@ -4952,6 +4952,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inherietFromRenamedNativeClass.kt")
|
||||
public void testInherietFromRenamedNativeClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsName/inherietFromRenamedNativeClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("jsName.kt")
|
||||
public void testJsName() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/jsName/jsName.kt");
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.js.config.LibrarySourcesConfig.UNKNOWN_EXTERNAL_MODULE_NAME;
|
||||
import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.getNameForAnnotatedObject;
|
||||
import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isLibraryObject;
|
||||
import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isNativeObject;
|
||||
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn;
|
||||
@@ -435,6 +436,10 @@ public final class StaticContext {
|
||||
if (descriptor instanceof LocalVariableDescriptor || descriptor instanceof ParameterDescriptor) {
|
||||
return getNameForDescriptor(descriptor);
|
||||
}
|
||||
if (isNativeObject(descriptor)) {
|
||||
String name = getNameForAnnotatedObject(descriptor);
|
||||
if (name != null) return rootFunction.getScope().declareName(name);
|
||||
}
|
||||
if (descriptor instanceof ConstructorDescriptor) {
|
||||
if (((ConstructorDescriptor) descriptor).isPrimary()) {
|
||||
return getInnerNameForDescriptor(((ConstructorDescriptor) descriptor).getConstructedClass());
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
function A(foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package foo
|
||||
|
||||
@native
|
||||
@JsName("A")
|
||||
open class B(val foo: String)
|
||||
|
||||
class C(s: String) : B(s)
|
||||
|
||||
fun box(): String {
|
||||
return C("OK").foo
|
||||
}
|
||||
Reference in New Issue
Block a user