Sometimes PsiClass'es are loaded twice for same class
This patch is workaround to fix tests.
This commit is contained in:
+37
-2
@@ -1220,6 +1220,41 @@ public class JavaDescriptorResolver {
|
|||||||
getAllTypeParameterDescriptorInitialization(supr, dest);
|
getAllTypeParameterDescriptorInitialization(supr, dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean equal(@NotNull PsiClass c1, @NotNull PsiClass c2) {
|
||||||
|
return c1.getQualifiedName().equals(c2.getQualifiedName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean equal(@NotNull PsiMethod m1, @NotNull PsiMethod m2) {
|
||||||
|
// TODO dummy
|
||||||
|
return m1.getName().equals(m2.getName()) && equal(m1.getContainingClass(), m2.getContainingClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean equal(@NotNull PsiTypeParameterListOwner o1, @NotNull PsiTypeParameterListOwner o2) {
|
||||||
|
if (o1 == o2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (o1 instanceof PsiClass && o2 instanceof PsiClass) {
|
||||||
|
return equal((PsiClass) o1, (PsiClass) o2);
|
||||||
|
}
|
||||||
|
if (o1 instanceof PsiMethod && o2 instanceof PsiMethod) {
|
||||||
|
return equal((PsiMethod) o1, (PsiMethod) o2);
|
||||||
|
}
|
||||||
|
if ((o1 instanceof PsiClass || o1 instanceof PsiMethod) && (o2 instanceof PsiClass || o2 instanceof PsiMethod)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
throw new IllegalStateException(o1.getClass() + ", " + o2.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean equal(@NotNull PsiTypeParameter p1, @NotNull PsiTypeParameter p2) {
|
||||||
|
if (p1 == p2) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (p1.getIndex() != p2.getIndex()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return equal(p1.getOwner(), p2.getOwner());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private FunctionDescriptor resolveMethodToFunctionDescriptor(ClassOrNamespaceDescriptor owner, final PsiClass psiClass, TypeSubstitutor typeSubstitutorForGenericSuperclasses, final PsiMethodWrapper method) {
|
private FunctionDescriptor resolveMethodToFunctionDescriptor(ClassOrNamespaceDescriptor owner, final PsiClass psiClass, TypeSubstitutor typeSubstitutorForGenericSuperclasses, final PsiMethodWrapper method) {
|
||||||
@@ -1320,12 +1355,12 @@ public class JavaDescriptorResolver {
|
|||||||
@Override
|
@Override
|
||||||
public TypeParameterDescriptor getTypeVariable(@NotNull PsiTypeParameter psiTypeParameter) {
|
public TypeParameterDescriptor getTypeVariable(@NotNull PsiTypeParameter psiTypeParameter) {
|
||||||
for (TypeParameterDescriptorInitialization typeParameter : methodTypeParametersInitialization) {
|
for (TypeParameterDescriptorInitialization typeParameter : methodTypeParametersInitialization) {
|
||||||
if (typeParameter.psiTypeParameter == psiTypeParameter) {
|
if (equal(typeParameter.psiTypeParameter, psiTypeParameter)) {
|
||||||
return typeParameter.descriptor;
|
return typeParameter.descriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (TypeParameterDescriptorInitialization typeParameter : classTypeParameterDescriptorsInitialization) {
|
for (TypeParameterDescriptorInitialization typeParameter : classTypeParameterDescriptorsInitialization) {
|
||||||
if (typeParameter.psiTypeParameter == psiTypeParameter) {
|
if (equal(typeParameter.psiTypeParameter, psiTypeParameter)) {
|
||||||
return typeParameter.descriptor;
|
return typeParameter.descriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ public class TypeVariableByPsiResolverImpl implements TypeVariableByPsiResolver
|
|||||||
@Override
|
@Override
|
||||||
public TypeParameterDescriptor getTypeVariable(@NotNull PsiTypeParameter psiTypeParameter) {
|
public TypeParameterDescriptor getTypeVariable(@NotNull PsiTypeParameter psiTypeParameter) {
|
||||||
for (JavaDescriptorResolver.TypeParameterDescriptorInitialization typeParameter : typeParameters) {
|
for (JavaDescriptorResolver.TypeParameterDescriptorInitialization typeParameter : typeParameters) {
|
||||||
if (typeParameter.psiTypeParameter == psiTypeParameter) {
|
if (JavaDescriptorResolver.equal(typeParameter.psiTypeParameter, psiTypeParameter)) {
|
||||||
return typeParameter.descriptor;
|
return typeParameter.descriptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user