hasConstructors() removed, a few members pulled up

This commit is contained in:
Andrey Breslav
2012-05-25 22:59:39 +04:00
parent af3f9250ef
commit 0182b87732
6 changed files with 30 additions and 47 deletions
@@ -44,8 +44,6 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor,
@Nullable @Nullable
ConstructorDescriptor getUnsubstitutedPrimaryConstructor(); ConstructorDescriptor getUnsubstitutedPrimaryConstructor();
boolean hasConstructors();
@Override @Override
@NotNull @NotNull
DeclarationDescriptor getContainingDeclaration(); DeclarationDescriptor getContainingDeclaration();
@@ -29,6 +29,9 @@ import java.util.Map;
*/ */
public abstract class ClassDescriptorBase implements ClassDescriptor { public abstract class ClassDescriptorBase implements ClassDescriptor {
protected TypeConstructor typeConstructor;
protected JetType defaultType;
protected abstract JetScope getScopeForMemberLookup(); protected abstract JetScope getScopeForMemberLookup();
@NotNull @NotNull
@@ -55,4 +58,29 @@ public abstract class ClassDescriptorBase implements ClassDescriptor {
} }
return new LazySubstitutingClassDescriptor(this, substitutor); return new LazySubstitutingClassDescriptor(this, substitutor);
} }
@NotNull
@Override
public TypeConstructor getTypeConstructor() {
return typeConstructor;
}
@NotNull
@Override
public JetType getDefaultType() {
if (defaultType == null) {
defaultType = TypeUtils.makeUnsubstitutedType(this, getScopeForMemberLookup());
}
return defaultType;
}
@Override
public void acceptVoid(DeclarationDescriptorVisitor<Void, Void> visitor) {
visitor.visitClassDescriptor(this, null);
}
@Override
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
return visitor.visitClassDescriptor(this, data);
}
} }
@@ -152,11 +152,6 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl
return primaryConstructor; return primaryConstructor;
} }
@Override
public boolean hasConstructors() {
return !constructors.isEmpty();
}
@Override @Override
@NotNull @NotNull
public Modality getModality() { public Modality getModality() {
@@ -126,11 +126,6 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
return original.getUnsubstitutedPrimaryConstructor(); return original.getUnsubstitutedPrimaryConstructor();
} }
@Override
public boolean hasConstructors() {
return original.hasConstructors();
}
@Override @Override
public List<AnnotationDescriptor> getAnnotations() { public List<AnnotationDescriptor> getAnnotations() {
return original.getAnnotations(); return original.getAnnotations();
@@ -46,14 +46,11 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
private List<TypeParameterDescriptor> typeParameters; private List<TypeParameterDescriptor> typeParameters;
private Collection<JetType> supertypes = Lists.newArrayList(); private Collection<JetType> supertypes = Lists.newArrayList();
private TypeConstructor typeConstructor;
private Modality modality; private Modality modality;
private Visibility visibility; private Visibility visibility;
private MutableClassDescriptorLite classObjectDescriptor; private MutableClassDescriptorLite classObjectDescriptor;
private JetType classObjectType; private JetType classObjectType;
private JetType defaultType;
private final ClassKind kind; private final ClassKind kind;
private JetScope scopeForMemberLookup; private JetScope scopeForMemberLookup;
@@ -116,12 +113,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
} }
} }
@NotNull
@Override
public TypeConstructor getTypeConstructor() {
return typeConstructor;
}
public void setScopeForMemberLookup(JetScope scopeForMemberLookup) { public void setScopeForMemberLookup(JetScope scopeForMemberLookup) {
this.scopeForMemberLookup = scopeForMemberLookup; this.scopeForMemberLookup = scopeForMemberLookup;
this.innerClassesScope = new InnerClassesScopeWrapper(scopeForMemberLookup); this.innerClassesScope = new InnerClassesScopeWrapper(scopeForMemberLookup);
@@ -132,7 +123,7 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
this.typeConstructor = new TypeConstructorImpl( this.typeConstructor = new TypeConstructorImpl(
this, this,
Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class? Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class?
!modality.isOverridable(), !getModality().isOverridable(),
getName().getName(), getName().getName(),
typeParameters, typeParameters,
supertypes); supertypes);
@@ -172,11 +163,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
} }
@Override
public boolean hasConstructors() {
return !constructors.isEmpty();
}
@NotNull @NotNull
@Override @Override
public ClassKind getKind() { public ClassKind getKind() {
@@ -232,15 +218,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
} }
} }
@NotNull
@Override
public JetType getDefaultType() {
if (defaultType == null) {
defaultType = TypeUtils.makeUnsubstitutedType(this, scopeForMemberLookup);
}
return defaultType;
}
@Override @Override
@Nullable @Nullable
public MutableClassDescriptorLite getClassObjectDescriptor() { public MutableClassDescriptorLite getClassObjectDescriptor() {
@@ -299,16 +276,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
} }
} }
@Override
public <R, D> R accept(DeclarationDescriptorVisitor<R, D> visitor, D data) {
return visitor.visitClassDescriptor(this, data);
}
@Override
public void acceptVoid(DeclarationDescriptorVisitor<Void, Void> visitor) {
visitor.visitClassDescriptor(this, null);
}
@Override @Override
public List<AnnotationDescriptor> getAnnotations() { public List<AnnotationDescriptor> getAnnotations() {
return annotations; return annotations;
@@ -211,7 +211,7 @@ public class BodyResolver {
if (supertype == null) return; if (supertype == null) return;
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype); ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
if (classDescriptor == null) return; if (classDescriptor == null) return;
if (descriptor.getKind() != ClassKind.TRAIT && classDescriptor.hasConstructors() && if (descriptor.getKind() != ClassKind.TRAIT && !classDescriptor.getConstructors().isEmpty() &&
!ErrorUtils.isError(classDescriptor.getTypeConstructor()) && classDescriptor.getKind() != ClassKind.TRAIT) { !ErrorUtils.isError(classDescriptor.getTypeConstructor()) && classDescriptor.getKind() != ClassKind.TRAIT) {
boolean hasConstructorWithoutParams = false; boolean hasConstructorWithoutParams = false;
for (ConstructorDescriptor constructor : classDescriptor.getConstructors()) { for (ConstructorDescriptor constructor : classDescriptor.getConstructors()) {