Drop JetClassObject element and its usages

as class objects are now represented by JetObjectDeclaration element
This commit is contained in:
Pavel V. Talanov
2015-01-21 14:44:18 +03:00
parent be7f5d01bb
commit d9d3f68a39
47 changed files with 87 additions and 411 deletions
@@ -99,9 +99,6 @@ public abstract class ClassBodyCodegen extends MemberCodegen<JetClassOrObject> {
genClassOrObject((JetClassOrObject) declaration);
}
else if (declaration instanceof JetClassObject) {
genClassOrObject(((JetClassObject) declaration).getObjectDeclaration());
}
}
private void generatePrimaryConstructorProperties(PropertyCodegen propertyCodegen, JetClassOrObject origin) {
@@ -150,7 +150,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
isStatic = !jetClass.isInner();
}
else {
isStatic = myClass.getParent() instanceof JetClassObject;
isStatic = myClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) myClass).isClassObject() ;
isFinal = true;
}
@@ -968,9 +968,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
fieldTypeDescriptor = descriptor;
}
else if (classObjectDescriptor != null) {
JetClassObject classObject = ((JetClass) myClass).getClassObject();
JetObjectDeclaration classObject = ((JetClass) myClass).getClassObject();
assert classObject != null : "Class object not found: " + myClass.getText();
original = classObject.getObjectDeclaration();
original = classObject;
fieldTypeDescriptor = classObjectDescriptor;
}
else {
@@ -207,46 +207,23 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitClassObject(@NotNull JetClassObject classObject) {
ClassDescriptor classDescriptor = bindingContext.get(CLASS, classObject.getObjectDeclaration());
public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) {
if (!filter.shouldProcessClass(declaration)) return;
assert classDescriptor != null : String.format("No class found in binding context for: \n---\n%s\n---\n",
JetPsiUtil.getElementTextWithContext(classObject));
ClassDescriptor classDescriptor = bindingContext.get(CLASS, declaration);
// working around a problem with shallow analysis
if (classDescriptor == null) return;
//TODO_R: remove visitClassObject
String name = getName(classDescriptor);
recordClosure(classDescriptor, name);
classStack.push(classDescriptor);
nameStack.push(name);
super.visitClassObject(classObject);
super.visitObjectDeclaration(declaration);
nameStack.pop();
classStack.pop();
}
@Override
public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) {
if (declaration.getParent() instanceof JetClassObject) {
super.visitObjectDeclaration(declaration);
}
else {
if (!filter.shouldProcessClass(declaration)) return;
ClassDescriptor classDescriptor = bindingContext.get(CLASS, declaration);
// working around a problem with shallow analysis
if (classDescriptor == null) return;
String name = getName(classDescriptor);
recordClosure(classDescriptor, name);
classStack.push(classDescriptor);
nameStack.push(name);
super.visitObjectDeclaration(declaration);
nameStack.pop();
classStack.pop();
}
}
@Override
public void visitClass(@NotNull JetClass klass) {
if (!filter.shouldProcessClass(klass)) return;
@@ -55,10 +55,6 @@ public final class PsiCodegenPredictor {
// TODO: Method won't give correct class name for traits implementations
JetDeclaration parentDeclaration = JetStubbedPsiUtil.getContainingDeclaration(declaration);
if (parentDeclaration instanceof JetClassObject) {
assert declaration instanceof JetObjectDeclaration : "Only object declarations can be children of JetClassObject: " + declaration;
return getPredefinedJvmInternalName(parentDeclaration);
}
String parentInternalName;
if (parentDeclaration != null) {
@@ -78,12 +74,6 @@ public final class PsiCodegenPredictor {
parentInternalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(containingFile.getPackageFqName());
}
if (declaration instanceof JetClassObject) {
// Get parent and assign Class object prefix
//TODO_R: getName() nullable
return parentInternalName + "$" + ((JetClassObject) declaration).getObjectDeclaration().getName();
}
if (!PsiTreeUtil.instanceOf(declaration, JetClass.class, JetObjectDeclaration.class, JetNamedFunction.class, JetProperty.class) ||
declaration instanceof JetEnumEntry) {
// Other subclasses are not valid for class name prediction.