mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
check method signatures equality by erasure; do not check method names for constructors.
note that erasure of type parameter is erasure of its left bound (jls), so erasure (T extends A & B) != erasure (T extends B & A) e.g. IDEA-74409
This commit is contained in:
@@ -45,7 +45,7 @@ public class MethodSignatureUtil {
|
||||
public static final TObjectHashingStrategy<MethodSignature> METHOD_PARAMETERS_ERASURE_EQUALITY =
|
||||
new TObjectHashingStrategy<MethodSignature>() {
|
||||
public int computeHashCode(final MethodSignature signature) {
|
||||
int result = signature.getName().hashCode();
|
||||
int result = signature.isConstructor() ? 0 : signature.getName().hashCode();
|
||||
|
||||
PsiType[] parameterTypes = signature.getParameterTypes();
|
||||
result += 37 * parameterTypes.length;
|
||||
@@ -58,7 +58,8 @@ public class MethodSignatureUtil {
|
||||
}
|
||||
|
||||
public boolean equals(MethodSignature method1, MethodSignature method2) {
|
||||
if (!method1.getName().equals(method2.getName())) return false;
|
||||
if (method1.isConstructor() != method2.isConstructor()) return false;
|
||||
if (!method1.isConstructor() && !method1.getName().equals(method2.getName())) return false;
|
||||
final PsiType[] parameterTypes1 = method1.getParameterTypes();
|
||||
final PsiType[] parameterTypes2 = method2.getParameterTypes();
|
||||
if (parameterTypes1.length != parameterTypes2.length) return false;
|
||||
@@ -122,6 +123,7 @@ public class MethodSignatureUtil {
|
||||
final MethodSignature superSignature,
|
||||
final PsiSubstitutor unifyingSubstitutor) {
|
||||
if (unifyingSubstitutor == null) return false;
|
||||
if (!METHOD_PARAMETERS_ERASURE_EQUALITY.equals(subSignature, superSignature)) return false;
|
||||
|
||||
final PsiType[] subParameterTypes = subSignature.getParameterTypes();
|
||||
final PsiType[] superParameterTypes = superSignature.getParameterTypes();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PsiSuperMethodUtil {
|
||||
PsiClass superClass = containingClass.getSuperClass();
|
||||
if (superClass != null) {
|
||||
MethodSignature defConstructor = MethodSignatureUtil.createMethodSignature(superClass.getName(), PsiType.EMPTY_ARRAY,
|
||||
PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
|
||||
PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY, true);
|
||||
return MethodSignatureUtil.findMethodBySignature(superClass, defConstructor, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user