Fix TypeConstructor#getSupertypes() return type

This commit is contained in:
Pavel V. Talanov
2012-11-07 15:32:34 +04:00
parent daf9c6f2c1
commit a657a19253
10 changed files with 12 additions and 11 deletions
@@ -60,7 +60,8 @@ public final class DescriptorResolverUtils {
return kind == ClassKind.CLASS || kind == ClassKind.TRAIT || kind == ClassKind.ENUM_CLASS; return kind == ClassKind.CLASS || kind == ClassKind.TRAIT || kind == ClassKind.ENUM_CLASS;
} }
public static Collection<? extends JetType> getSupertypes(@NotNull ClassOrNamespaceDescriptor classOrNamespaceDescriptor) { @NotNull
public static Collection<JetType> getSupertypes(@NotNull ClassOrNamespaceDescriptor classOrNamespaceDescriptor) {
if (classOrNamespaceDescriptor instanceof ClassDescriptor) { if (classOrNamespaceDescriptor instanceof ClassDescriptor) {
return ((ClassDescriptor) classOrNamespaceDescriptor).getTypeConstructor().getSupertypes(); return ((ClassDescriptor) classOrNamespaceDescriptor).getTypeConstructor().getSupertypes();
} }
@@ -259,7 +259,7 @@ public class DescriptorUtils {
@NotNull @NotNull
public static List<ClassDescriptor> getSuperclassDescriptors(@NotNull ClassDescriptor classDescriptor) { public static List<ClassDescriptor> getSuperclassDescriptors(@NotNull ClassDescriptor classDescriptor) {
Collection<? extends JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes(); Collection<JetType> superclassTypes = classDescriptor.getTypeConstructor().getSupertypes();
List<ClassDescriptor> superClassDescriptors = new ArrayList<ClassDescriptor>(); List<ClassDescriptor> superClassDescriptors = new ArrayList<ClassDescriptor>();
for (JetType type : superclassTypes) { for (JetType type : superclassTypes) {
ClassDescriptor result = getClassDescriptorForType(type); ClassDescriptor result = getClassDescriptorForType(type);
@@ -346,7 +346,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
@NotNull @NotNull
@Override @Override
public Collection<? extends JetType> getSupertypes() { public Collection<JetType> getSupertypes() {
if (supertypes == null) { if (supertypes == null) {
if (resolveSession.isClassSpecial(DescriptorUtils.getFQName(LazyClassDescriptor.this))) { if (resolveSession.isClassSpecial(DescriptorUtils.getFQName(LazyClassDescriptor.this))) {
this.supertypes = Collections.emptyList(); this.supertypes = Collections.emptyList();
@@ -180,7 +180,7 @@ public class LazyTypeParameterDescriptor implements TypeParameterDescriptor, Laz
typeConstructor = new TypeConstructor() { typeConstructor = new TypeConstructor() {
@NotNull @NotNull
@Override @Override
public Collection<? extends JetType> getSupertypes() { public Collection<JetType> getSupertypes() {
return LazyTypeParameterDescriptor.this.getUpperBounds(); return LazyTypeParameterDescriptor.this.getUpperBounds();
} }
@@ -47,7 +47,7 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo
@NotNull @NotNull
@Override @Override
public Collection<? extends JetType> getSupertypes() { public Collection<JetType> getSupertypes() {
return intersectedTypes; return intersectedTypes;
} }
@@ -33,7 +33,7 @@ public interface TypeConstructor extends Annotated {
List<TypeParameterDescriptor> getParameters(); List<TypeParameterDescriptor> getParameters();
@NotNull @NotNull
Collection<? extends JetType> getSupertypes(); Collection<JetType> getSupertypes();
boolean isSealed(); boolean isSealed();
@@ -445,7 +445,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
) { ) {
JetType result = null; JetType result = null;
JetType thisType = thisReceiver.getType(); JetType thisType = thisReceiver.getType();
Collection<? extends JetType> supertypes = thisType.getConstructor().getSupertypes(); Collection<JetType> supertypes = thisType.getConstructor().getSupertypes();
TypeSubstitutor substitutor = TypeSubstitutor.create(thisType); TypeSubstitutor substitutor = TypeSubstitutor.create(thisType);
JetTypeReference superTypeQualifier = expression.getSuperTypeQualifier(); JetTypeReference superTypeQualifier = expression.getSuperTypeQualifier();
@@ -611,12 +611,12 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
renderTypeParameters(descriptor.getTypeConstructor().getParameters(), builder); renderTypeParameters(descriptor.getTypeConstructor().getParameters(), builder);
} }
if (!descriptor.equals(KotlinBuiltIns.getInstance().getNothing())) { if (!descriptor.equals(KotlinBuiltIns.getInstance().getNothing())) {
Collection<? extends JetType> supertypes = descriptor.getTypeConstructor().getSupertypes(); Collection<JetType> supertypes = descriptor.getTypeConstructor().getSupertypes();
if (supertypes.isEmpty() || supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAny(supertypes.iterator().next())) { if (supertypes.isEmpty() || supertypes.size() == 1 && KotlinBuiltIns.getInstance().isAny(supertypes.iterator().next())) {
} }
else { else {
builder.append(" : "); builder.append(" : ");
for (Iterator<? extends JetType> iterator = supertypes.iterator(); iterator.hasNext(); ) { for (Iterator<JetType> iterator = supertypes.iterator(); iterator.hasNext(); ) {
JetType supertype = iterator.next(); JetType supertype = iterator.next();
builder.append(renderType(supertype)); builder.append(renderType(supertype));
if (iterator.hasNext()) { if (iterator.hasNext()) {
@@ -67,7 +67,7 @@ public class GotoSuperActionHandler implements CodeInsightActionHandler {
Collection<? extends DeclarationDescriptor> superDescriptors; Collection<? extends DeclarationDescriptor> superDescriptors;
String message; String message;
if (descriptor instanceof ClassDescriptor) { if (descriptor instanceof ClassDescriptor) {
Collection<? extends JetType> supertypes = ((ClassDescriptor) descriptor).getTypeConstructor().getSupertypes(); Collection<JetType> supertypes = ((ClassDescriptor) descriptor).getTypeConstructor().getSupertypes();
List<ClassDescriptor> superclasses = ContainerUtil.mapNotNull(supertypes, new Function<JetType, ClassDescriptor>() { List<ClassDescriptor> superclasses = ContainerUtil.mapNotNull(supertypes, new Function<JetType, ClassDescriptor>() {
@Override @Override
public ClassDescriptor fun(JetType type) { public ClassDescriptor fun(JetType type) {
@@ -182,7 +182,7 @@ public final class ClassTranslator extends AbstractTranslator {
@NotNull @NotNull
private List<JsExpression> getSupertypesNameReferences() { private List<JsExpression> getSupertypesNameReferences() {
Collection<? extends JetType> supertypes = descriptor.getTypeConstructor().getSupertypes(); Collection<JetType> supertypes = descriptor.getTypeConstructor().getSupertypes();
if (supertypes.isEmpty()) { if (supertypes.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }