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
ConstructorDescriptor getUnsubstitutedPrimaryConstructor();
boolean hasConstructors();
@Override
@NotNull
DeclarationDescriptor getContainingDeclaration();
@@ -29,6 +29,9 @@ import java.util.Map;
*/
public abstract class ClassDescriptorBase implements ClassDescriptor {
protected TypeConstructor typeConstructor;
protected JetType defaultType;
protected abstract JetScope getScopeForMemberLookup();
@NotNull
@@ -55,4 +58,29 @@ public abstract class ClassDescriptorBase implements ClassDescriptor {
}
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;
}
@Override
public boolean hasConstructors() {
return !constructors.isEmpty();
}
@Override
@NotNull
public Modality getModality() {
@@ -126,11 +126,6 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
return original.getUnsubstitutedPrimaryConstructor();
}
@Override
public boolean hasConstructors() {
return original.hasConstructors();
}
@Override
public List<AnnotationDescriptor> getAnnotations() {
return original.getAnnotations();
@@ -46,14 +46,11 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
private List<TypeParameterDescriptor> typeParameters;
private Collection<JetType> supertypes = Lists.newArrayList();
private TypeConstructor typeConstructor;
private Modality modality;
private Visibility visibility;
private MutableClassDescriptorLite classObjectDescriptor;
private JetType classObjectType;
private JetType defaultType;
private final ClassKind kind;
private JetScope scopeForMemberLookup;
@@ -116,12 +113,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
}
}
@NotNull
@Override
public TypeConstructor getTypeConstructor() {
return typeConstructor;
}
public void setScopeForMemberLookup(JetScope scopeForMemberLookup) {
this.scopeForMemberLookup = scopeForMemberLookup;
this.innerClassesScope = new InnerClassesScopeWrapper(scopeForMemberLookup);
@@ -132,7 +123,7 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
this.typeConstructor = new TypeConstructorImpl(
this,
Collections.<AnnotationDescriptor>emptyList(), // TODO : pass annotations from the class?
!modality.isOverridable(),
!getModality().isOverridable(),
getName().getName(),
typeParameters,
supertypes);
@@ -172,11 +163,6 @@ public class MutableClassDescriptorLite extends ClassDescriptorBase
}
@Override
public boolean hasConstructors() {
return !constructors.isEmpty();
}
@NotNull
@Override
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
@Nullable
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
public List<AnnotationDescriptor> getAnnotations() {
return annotations;
@@ -211,7 +211,7 @@ public class BodyResolver {
if (supertype == null) return;
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(supertype);
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) {
boolean hasConstructorWithoutParams = false;
for (ConstructorDescriptor constructor : classDescriptor.getConstructors()) {