[KT-4124] Minor refactoring and cleanup
This commit is contained in:
+4
@@ -1,3 +1,7 @@
|
||||
class A {
|
||||
<!NATIVE_INNER_CLASS_PROHIBITED!>@native inner class B<!>
|
||||
}
|
||||
|
||||
@native class C {
|
||||
@native inner class D
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
@kotlin.js.native() public final inner class B {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.js.native() public final class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
@kotlin.js.native() public final inner class D {
|
||||
public constructor D()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
package
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
@kotlin.js.native() public final inner class B {
|
||||
public constructor B()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -498,9 +498,9 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib/native/nested"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("nativeNestedClassProhibited.kt")
|
||||
public void testNativeNestedClassProhibited() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nested/nativeNestedClassProhibited.kt");
|
||||
@TestMetadata("nativeInnerClassProhibited.kt")
|
||||
public void testNativeInnerClassProhibited() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/native/nested/nativeInnerClassProhibited.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -4117,6 +4117,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataLocalVariable.kt")
|
||||
public void testDataLocalVariable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/functions/dataLocalVariable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultargs.kt")
|
||||
public void testDefaultargs() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/functions/defaultargs.kt");
|
||||
@@ -4642,12 +4648,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("dataLocalVariable.kt")
|
||||
public void testDataLocalVariable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/dataLocalVariable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFun.kt")
|
||||
public void testExtensionFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/extensionFun.kt");
|
||||
|
||||
@@ -31,12 +31,6 @@ import java.util.regex.Pattern;
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class InnerNestedTestGenerated extends AbstractInnerNestedTest {
|
||||
@TestMetadata("dataLocalVariable.kt")
|
||||
public void ignoredDataLocalVariable() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/innerNested/dataLocalVariable.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInnerNested() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/innerNested"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
+1
-6
@@ -387,7 +387,7 @@ public class TranslationContext {
|
||||
}
|
||||
ClassDescriptor parentDescriptor = parent.classDescriptor;
|
||||
if (classDescriptor != parentDescriptor) {
|
||||
return new JsNameRef("$outer", parent.getDispatchReceiverPath(cls));
|
||||
return new JsNameRef(Namer.OUTER_FIELD_NAME, parent.getDispatchReceiverPath(cls));
|
||||
}
|
||||
else {
|
||||
return parent.getDispatchReceiverPath(cls);
|
||||
@@ -445,9 +445,4 @@ public class TranslationContext {
|
||||
assert descriptor != null : "Missing declaration descriptor: " + PsiUtilsKt.getTextWithLocation(expression);
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public boolean isLocal() {
|
||||
DeclarationDescriptor descriptor = declarationDescriptor;
|
||||
return descriptor != null && DescriptorUtils.isLocal(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -166,8 +166,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
|
||||
assert superDescriptor != null : "This class is expected to have super class: "
|
||||
+ PsiUtilsKt.getTextWithLocation(classDeclaration);
|
||||
if (superDescriptor.isInner() && descriptor.isInner()) {
|
||||
arguments = new ArrayList<JsExpression>(arguments);
|
||||
arguments.add(0, new JsNameRef("$outer", JsLiteral.THIS));
|
||||
arguments.add(0, new JsNameRef(Namer.OUTER_FIELD_NAME, JsLiteral.THIS));
|
||||
}
|
||||
addCallToSuperMethod(arguments, initializer);
|
||||
}
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public final class ReferenceTranslator {
|
||||
// Ignore qualifier if expression is EnumEntry or companion object reference and always use FQ name.
|
||||
DeclarationDescriptor descriptor = BindingUtils.getDescriptorForReferenceExpression(context.bindingContext(), expression);
|
||||
//TODO: should go away when objects inside classes are supported
|
||||
if (DescriptorUtils.isCompanionObject(descriptor) && !AnnotationsUtils.isNativeObject(descriptor)) {
|
||||
if (descriptor != null && DescriptorUtils.isCompanionObject(descriptor) && !AnnotationsUtils.isNativeObject(descriptor)) {
|
||||
return simpleName;
|
||||
}
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
@@ -67,7 +67,7 @@ public final class ReferenceTranslator {
|
||||
qualifier = Namer.getCompanionObjectAccessor(translateAsFQReference(enumClass, context));
|
||||
}
|
||||
}
|
||||
else if (entryClass.getKind() == ClassKind.CLASS || entryClass.getKind() == ClassKind.ENUM_CLASS) {
|
||||
else if (DescriptorUtils.isClassOrEnumClass(entryClass)) {
|
||||
qualifier = null;
|
||||
}
|
||||
}
|
||||
|
||||
+17
-30
@@ -151,11 +151,20 @@ var Kotlin = {};
|
||||
return object;
|
||||
}
|
||||
|
||||
Kotlin.doCreateClass = function (metadata, constructor) {
|
||||
/**
|
||||
* @param {(Array|Object|null)=} bases
|
||||
* @param {(function(new: T, ?, ?, ?, ?, ?, ?, ?): T)|null=} constructor
|
||||
* @param {Object=} properties
|
||||
* @param {Object=} staticProperties
|
||||
* @returns {function(new: T): T}
|
||||
* @template T
|
||||
*/
|
||||
Kotlin.createClassNow = function (bases, constructor, properties, staticProperties) {
|
||||
if (constructor == null) {
|
||||
constructor = emptyFunction();
|
||||
}
|
||||
|
||||
var metadata = computeMetadata(bases, properties, staticProperties);
|
||||
metadata.type = Kotlin.TYPE.CLASS;
|
||||
copyProperties(constructor, metadata.staticMembers);
|
||||
|
||||
@@ -169,7 +178,7 @@ var Kotlin = {};
|
||||
Object.defineProperties(prototypeObj, metadata.properties);
|
||||
copyProperties(prototypeObj, metadata.functions);
|
||||
prototypeObj.constructor = constructor;
|
||||
Kotlin.defineInnerTypes(constructor, metadata.types);
|
||||
defineNestedTypes(constructor, metadata.types);
|
||||
|
||||
if (metadata.baseClass != null) {
|
||||
constructor.baseInitializer = metadata.baseClass;
|
||||
@@ -181,20 +190,7 @@ var Kotlin = {};
|
||||
return constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {(Array|Object|null)=} bases
|
||||
* @param {(function(new: T, ?, ?, ?, ?, ?, ?, ?): T)|null=} constructor
|
||||
* @param {Object=} properties
|
||||
* @param {Object=} staticProperties
|
||||
* @returns {function(new: T): T}
|
||||
* @template T
|
||||
*/
|
||||
Kotlin.createClassNow = function (bases, constructor, properties, staticProperties) {
|
||||
var metadata = computeMetadata(bases, properties, staticProperties);
|
||||
return Kotlin.doCreateClass(metadata, constructor);
|
||||
};
|
||||
|
||||
Kotlin.defineInnerTypes = function(constructor, types) {
|
||||
function defineNestedTypes(constructor, types) {
|
||||
for (var innerTypeName in types) {
|
||||
// since types object does not inherit from anything, it's just a map
|
||||
//noinspection JSUnfilteredForInLoop
|
||||
@@ -206,21 +202,13 @@ var Kotlin = {};
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Kotlin.createObjectNow = function (bases, constructor, functions, staticProperties) {
|
||||
var metadata = computeMetadata(bases, functions, staticProperties);
|
||||
var noNameClass = Kotlin.doCreateClass(metadata, constructor);
|
||||
var noNameClass = Kotlin.createClassNow(bases, constructor, functions, staticProperties);
|
||||
var obj = new noNameClass();
|
||||
noNameClass.$metadata$.type = Kotlin.TYPE.OBJECT;
|
||||
for (var innerTypeName in metadata.types) {
|
||||
// since types object does not inherit from anything, it's just a map
|
||||
//noinspection JSUnfilteredForInLoop
|
||||
Object.defineProperty(obj, innerTypeName, {
|
||||
get : metadata.types[innerTypeName],
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
defineNestedTypes(obj, noNameClass.$metadata$.types);
|
||||
return obj;
|
||||
};
|
||||
|
||||
@@ -236,7 +224,7 @@ var Kotlin = {};
|
||||
copyProperties(obj.prototype, obj.$metadata$.functions);
|
||||
Object.defineProperty(obj, "object", {get: class_object, configurable: true});
|
||||
|
||||
Kotlin.defineInnerTypes(constructor, obj.$metadata$.types);
|
||||
defineNestedTypes(constructor, obj.$metadata$.types);
|
||||
return obj;
|
||||
};
|
||||
|
||||
@@ -258,8 +246,7 @@ var Kotlin = {};
|
||||
*/
|
||||
Kotlin.createClass = function (basesFun, constructor, properties, staticProperties) {
|
||||
function $o() {
|
||||
var metadata = computeMetadata(getBases(basesFun), properties, staticProperties);
|
||||
var klass = Kotlin.doCreateClass(metadata, constructor);
|
||||
var klass = Kotlin.createClassNow(getBases(basesFun), constructor, properties, staticProperties);
|
||||
Object.defineProperty(this, $o.className, {value: klass});
|
||||
return klass;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user