isReified() for type parameters
This commit is contained in:
+1
@@ -189,6 +189,7 @@ public class JavaDescriptorResolver {
|
||||
TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptor.createForFurtherModification(
|
||||
owner,
|
||||
Collections.<AnnotationDescriptor>emptyList(), // TODO
|
||||
false,
|
||||
Variance.INVARIANT,
|
||||
typeParameter.getName(),
|
||||
typeParameter.getIndex()
|
||||
|
||||
+13
-3
@@ -21,10 +21,11 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
public static TypeParameterDescriptor createWithDefaultBound(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull String name,
|
||||
int index) {
|
||||
TypeParameterDescriptor typeParameterDescriptor = createForFurtherModification(containingDeclaration, annotations, variance, name, index);
|
||||
TypeParameterDescriptor typeParameterDescriptor = createForFurtherModification(containingDeclaration, annotations, reified, variance, name, index);
|
||||
typeParameterDescriptor.addUpperBound(JetStandardClasses.getDefaultBound());
|
||||
return typeParameterDescriptor;
|
||||
}
|
||||
@@ -32,10 +33,11 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
public static TypeParameterDescriptor createForFurtherModification(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull String name,
|
||||
int index) {
|
||||
return new TypeParameterDescriptor(containingDeclaration, annotations, variance, name, index);
|
||||
return new TypeParameterDescriptor(containingDeclaration, annotations, reified, variance, name, index);
|
||||
}
|
||||
|
||||
private final int index;
|
||||
@@ -47,9 +49,12 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
private final Set<JetType> classObjectUpperBounds = Sets.newLinkedHashSet();
|
||||
private JetType classObjectBoundsAsType;
|
||||
|
||||
private final boolean reified;
|
||||
|
||||
private TypeParameterDescriptor(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull List<AnnotationDescriptor> annotations,
|
||||
boolean reified,
|
||||
@NotNull Variance variance,
|
||||
@NotNull String name,
|
||||
int index) {
|
||||
@@ -57,6 +62,7 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
this.index = index;
|
||||
this.variance = variance;
|
||||
this.upperBounds = Sets.newLinkedHashSet();
|
||||
this.reified = reified;
|
||||
// TODO: Should we actually pass the annotations on to the type constructor?
|
||||
this.typeConstructor = new TypeConstructorImpl(
|
||||
this,
|
||||
@@ -67,6 +73,10 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
upperBounds);
|
||||
}
|
||||
|
||||
public boolean isReified() {
|
||||
return reified;
|
||||
}
|
||||
|
||||
public Variance getVariance() {
|
||||
return variance;
|
||||
}
|
||||
@@ -162,6 +172,6 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
|
||||
|
||||
@NotNull
|
||||
public TypeParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
||||
return new TypeParameterDescriptor(newOwner, Lists.newArrayList(getAnnotations()), variance, getName(), index);
|
||||
return new TypeParameterDescriptor(newOwner, Lists.newArrayList(getAnnotations()), reified, variance, getName(), index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class ClassDescriptorResolver {
|
||||
TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptor.createForFurtherModification(
|
||||
descriptor,
|
||||
annotationResolver.createAnnotationStubs(typeParameter.getModifierList()),
|
||||
true,
|
||||
typeParameter.getVariance(),
|
||||
JetPsiUtil.safeName(typeParameter.getName()),
|
||||
index
|
||||
@@ -313,6 +314,7 @@ public class ClassDescriptorResolver {
|
||||
TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptor.createForFurtherModification(
|
||||
containingDescriptor,
|
||||
annotationResolver.createAnnotationStubs(typeParameter.getModifierList()),
|
||||
true,
|
||||
typeParameter.getVariance(),
|
||||
JetPsiUtil.safeName(typeParameter.getName()),
|
||||
index
|
||||
|
||||
@@ -40,6 +40,7 @@ public class DescriptorSubstitutor {
|
||||
TypeParameterDescriptor substituted = TypeParameterDescriptor.createForFurtherModification(
|
||||
newContainingDeclaration,
|
||||
descriptor.getAnnotations(),
|
||||
descriptor.isReified(),
|
||||
descriptor.getVariance(),
|
||||
descriptor.getName(),
|
||||
descriptor.getIndex());
|
||||
|
||||
@@ -116,7 +116,7 @@ public class JetStandardClasses {
|
||||
parameters.add(TypeParameterDescriptor.createWithDefaultBound(
|
||||
classDescriptor,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Variance.OUT_VARIANCE, "T" + j, j));
|
||||
true, Variance.OUT_VARIANCE, "T" + j, j));
|
||||
}
|
||||
TUPLE[i] = classDescriptor.initialize(
|
||||
true,
|
||||
@@ -159,7 +159,7 @@ public class JetStandardClasses {
|
||||
parameters.add(0, TypeParameterDescriptor.createWithDefaultBound(
|
||||
receiverFunction,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Variance.IN_VARIANCE, "T", 0));
|
||||
true, Variance.IN_VARIANCE, "T", 0));
|
||||
RECEIVER_FUNCTION[i] = receiverFunction.initialize(
|
||||
false,
|
||||
parameters,
|
||||
@@ -174,12 +174,12 @@ public class JetStandardClasses {
|
||||
parameters.add(TypeParameterDescriptor.createWithDefaultBound(
|
||||
function,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Variance.IN_VARIANCE, "P" + j, j + 1));
|
||||
true, Variance.IN_VARIANCE, "P" + j, j + 1));
|
||||
}
|
||||
parameters.add(TypeParameterDescriptor.createWithDefaultBound(
|
||||
function,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Variance.OUT_VARIANCE, "R", parameterCount + 1));
|
||||
true, Variance.OUT_VARIANCE, "R", parameterCount + 1));
|
||||
return parameters;
|
||||
}
|
||||
|
||||
|
||||
@@ -311,6 +311,9 @@ public class DescriptorRenderer implements Renderer {
|
||||
}
|
||||
|
||||
protected void renderTypeParameter(TypeParameterDescriptor descriptor, StringBuilder builder) {
|
||||
if (!descriptor.isReified()) {
|
||||
builder.append(renderKeyword("erased")).append(" ");
|
||||
}
|
||||
renderName(descriptor, builder);
|
||||
if (!descriptor.getUpperBounds().isEmpty()) {
|
||||
JetType bound = descriptor.getUpperBounds().iterator().next();
|
||||
|
||||
Reference in New Issue
Block a user