DeclarationDescriptors returned from type constructors

This commit is contained in:
Andrey Breslav
2011-03-15 13:52:16 +03:00
parent 0388171d88
commit 68d60f2b8b
6 changed files with 25 additions and 4 deletions
@@ -70,6 +70,7 @@ public class ClassDescriptorResolver {
descriptor.setTypeConstructor(
new TypeConstructor(
descriptor,
AttributeResolver.INSTANCE.resolveAttributes(classElement.getModifierList()),
!open,
classElement.getName(),
@@ -33,7 +33,7 @@ public class ClassDescriptorImpl extends DeclarationDescriptorImpl implements Cl
public final ClassDescriptorImpl initialize(boolean sealed,
List<TypeParameterDescriptor> typeParameters,
Collection<? extends JetType> superclasses, JetScope memberDeclarations) {
this.typeConstructor = new TypeConstructor(getAttributes(), sealed, getName(), typeParameters, superclasses);
this.typeConstructor = new TypeConstructor(this, getAttributes(), sealed, getName(), typeParameters, superclasses);
this.memberDeclarations = memberDeclarations;
return this;
}
@@ -63,7 +63,7 @@ public class ErrorType {
}
private static JetType createErrorType(String debugMessage, JetScope memberScope) {
return new ErrorTypeImpl(new TypeConstructor(Collections.<Attribute>emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.<TypeParameterDescriptor>emptyList(), Collections.<JetType>emptyList()), memberScope);
return new ErrorTypeImpl(new TypeConstructor(null, Collections.<Attribute>emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.<TypeParameterDescriptor>emptyList(), Collections.<JetType>emptyList()), memberScope);
}
public static JetType createWrongVarianceErrorType(TypeProjection value) {
@@ -1,5 +1,8 @@
package org.jetbrains.jet.lang.types;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -13,18 +16,30 @@ public class TypeConstructor extends AnnotatedImpl {
private final String debugName;
private final boolean sealed;
public TypeConstructor(List<Attribute> attributes, boolean sealed, String debugName, List<TypeParameterDescriptor> parameters, Collection<? extends JetType> supertypes) {
@Nullable
private final DeclarationDescriptor declarationDescriptor;
public TypeConstructor(
@Nullable DeclarationDescriptor declarationDescriptor,
@NotNull List<Attribute> attributes,
boolean sealed,
@NotNull String debugName,
@NotNull List<TypeParameterDescriptor> parameters,
@NotNull Collection<? extends JetType> supertypes) {
super(attributes);
this.declarationDescriptor = declarationDescriptor;
this.sealed = sealed;
this.debugName = debugName;
this.parameters = new ArrayList<TypeParameterDescriptor>(parameters);
this.supertypes = supertypes;
}
@NotNull
public List<TypeParameterDescriptor> getParameters() {
return parameters;
}
@NotNull
public Collection<? extends JetType> getSupertypes() {
return supertypes;
}
@@ -38,4 +53,8 @@ public class TypeConstructor extends AnnotatedImpl {
return sealed;
}
@Nullable
public DeclarationDescriptor getDeclarationDescriptor() {
return declarationDescriptor;
}
}
@@ -20,6 +20,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl {
this.upperBounds = upperBounds;
// TODO: Should we actually pass the attributes on to the type constructor?
this.typeConstructor = new TypeConstructor(
this,
attributes,
false,
"&" + name,
@@ -56,7 +56,7 @@ public class TypeUtils {
}
List<Attribute> noAttributes = Collections.<Attribute>emptyList();
TypeConstructor constructor = new TypeConstructor(noAttributes, false, debugName.toString(), Collections.<TypeParameterDescriptor>emptyList(), types);
TypeConstructor constructor = new TypeConstructor(null, noAttributes, false, debugName.toString(), Collections.<TypeParameterDescriptor>emptyList(), types);
return new JetTypeImpl(
noAttributes,
constructor,