Treat anonymous objects as classes (ClassKind.CLASS)
They're not objects per se, i.e. they're not singletons
This commit is contained in:
@@ -252,6 +252,10 @@ public class AsmUtil {
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
}
|
||||
if (memberDescriptor instanceof ConstructorDescriptor) {
|
||||
if (isAnonymousObject(containingDeclaration)) {
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
}
|
||||
|
||||
ClassKind kind = ((ClassDescriptor) containingDeclaration).getKind();
|
||||
if (kind == ClassKind.OBJECT) {
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
|
||||
@@ -34,8 +34,6 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
@@ -87,10 +85,6 @@ public class CodegenUtil {
|
||||
return invokeDescriptor;
|
||||
}
|
||||
|
||||
public static boolean isNonLiteralObject(JetClassOrObject myClass) {
|
||||
return myClass instanceof JetObjectDeclaration && !((JetObjectDeclaration) myClass).isObjectLiteral();
|
||||
}
|
||||
|
||||
public static String createTmpVariableName(Collection<String> existingNames) {
|
||||
String prefix = "tmp";
|
||||
int i = RANDOM.nextInt(Integer.MAX_VALUE);
|
||||
|
||||
@@ -1028,35 +1028,35 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
iv.load(0, OBJECT_TYPE);
|
||||
}
|
||||
|
||||
for (int paramIndex = 0; paramIndex < argTypes.length; paramIndex++) {
|
||||
Type argType = argTypes[paramIndex];
|
||||
for (Type argType : argTypes) {
|
||||
iv.load(reg, argType);
|
||||
//noinspection AssignmentToForLoopParameter
|
||||
reg += argType.getSize();
|
||||
}
|
||||
callableMethod.invokeWithoutAssertions(iv);
|
||||
}
|
||||
|
||||
private void generateFieldForSingleton() {
|
||||
boolean hasClassObject = descriptor.getClassObjectDescriptor() != null;
|
||||
boolean isEnumClass = DescriptorUtils.isEnumClass(descriptor);
|
||||
boolean isObjectDeclaration = descriptor.getKind() == ClassKind.OBJECT && isNonLiteralObject(myClass) ;
|
||||
if (isEnumClass(descriptor)) return;
|
||||
|
||||
if (!isObjectDeclaration && !hasClassObject || isEnumClass) return;
|
||||
|
||||
ClassDescriptor fieldTypeDescriptor = hasClassObject ? descriptor.getClassObjectDescriptor() : descriptor;
|
||||
assert fieldTypeDescriptor != null;
|
||||
StackValue.Field field = StackValue.singleton(fieldTypeDescriptor, typeMapper);
|
||||
ClassDescriptor classObjectDescriptor = descriptor.getClassObjectDescriptor();
|
||||
ClassDescriptor fieldTypeDescriptor;
|
||||
JetClassOrObject original;
|
||||
if (hasClassObject) {
|
||||
if (isObject(descriptor)) {
|
||||
original = myClass;
|
||||
fieldTypeDescriptor = descriptor;
|
||||
}
|
||||
else if (classObjectDescriptor != null) {
|
||||
JetClassObject classObject = ((JetClass) myClass).getClassObject();
|
||||
assert classObject != null : myClass.getText();
|
||||
assert classObject != null : "Class object not found: " + myClass.getText();
|
||||
original = classObject.getObjectDeclaration();
|
||||
fieldTypeDescriptor = classObjectDescriptor;
|
||||
}
|
||||
else {
|
||||
original = myClass;
|
||||
return;
|
||||
}
|
||||
|
||||
StackValue.Field field = StackValue.singleton(fieldTypeDescriptor, typeMapper);
|
||||
|
||||
v.newField(original, ACC_PUBLIC | ACC_STATIC | ACC_FINAL, field.name, field.type.getDescriptor(), null, null);
|
||||
|
||||
if (!AsmUtil.isClassObjectWithBackingFieldsInOuter(fieldTypeDescriptor)) {
|
||||
|
||||
Reference in New Issue
Block a user