'isSubclass' method refactoring: not collecting all supertypes
This commit is contained in:
@@ -18,7 +18,6 @@ package org.jetbrains.jet.lang.resolve;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import gnu.trove.THashSet;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
@@ -279,20 +278,21 @@ public class DescriptorUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSubclass(ClassDescriptor subClass, ClassDescriptor superClass) {
|
public static boolean isSubclass(@NotNull ClassDescriptor subClass, @NotNull ClassDescriptor superClass) {
|
||||||
Set<JetType> allSuperTypes = new THashSet<JetType>();
|
DeclarationDescriptor superOriginal = superClass.getOriginal();
|
||||||
|
return hasEqualSuperType(subClass.getDefaultType(), superOriginal);
|
||||||
|
}
|
||||||
|
|
||||||
addSuperTypes(subClass.getDefaultType(), allSuperTypes);
|
private static boolean hasEqualSuperType(@NotNull JetType type, @NotNull DeclarationDescriptor superOriginal) {
|
||||||
|
DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
final DeclarationDescriptor superOriginal = superClass.getOriginal();
|
if (descriptor != null && superOriginal.equals(descriptor.getOriginal())) {
|
||||||
|
return true;
|
||||||
for (JetType superType : allSuperTypes) {
|
}
|
||||||
final DeclarationDescriptor descriptor = superType.getConstructor().getDeclarationDescriptor();
|
for (JetType superType : type.getConstructor().getSupertypes()) {
|
||||||
if (descriptor != null && superOriginal.equals(descriptor.getOriginal())) {
|
if (hasEqualSuperType(superType, superOriginal)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user