good code red: do not apply the same substitutor twice - lead to problems when params depend recursively (IDEA-91866)

This commit is contained in:
anna
2012-09-21 16:50:12 +02:00
parent e3a545b2d0
commit e483d67491
3 changed files with 24 additions and 3 deletions
@@ -121,7 +121,7 @@ public class HighlightMethodUtil {
for (MethodSignatureBackedByPsiMethod superMethodSignature : superMethodSignatures) {
PsiMethod superMethod = superMethodSignature.getMethod();
PsiType declaredReturnType = superMethod.getReturnType();
PsiType superReturnType = superMethodSignature.getSubstitutor().substitute(declaredReturnType);
PsiType superReturnType = declaredReturnType;
if (superMethodSignature.isRaw()) superReturnType = TypeConversionUtil.erasure(declaredReturnType);
if (returnType == null || superReturnType == null || method == superMethod) continue;
PsiClass superClass = superMethod.getContainingClass();
@@ -151,10 +151,10 @@ public class HighlightMethodUtil {
superMethodSignature);
substitutedSuperReturnType = unifyingSubstitutor == null
? superReturnType
: unifyingSubstitutor.substitute(superMethodSignature.getSubstitutor().substitute(superReturnType));
: unifyingSubstitutor.substitute(superReturnType);
}
else {
substitutedSuperReturnType = TypeConversionUtil.erasure(superReturnType);
substitutedSuperReturnType = TypeConversionUtil.erasure(superMethodSignature.getSubstitutor().substitute(superReturnType));
}
if (returnType.equals(substitutedSuperReturnType)) return null;
@@ -0,0 +1,20 @@
abstract class F<A, B> {
public abstract B f(A a);
public final F<A, P1<B>> lazy() {
return new F<A, P1<B>>() {
public P1<B> f(final A a) {
return null;
}
};
}
private class TestClient<A, B> extends F<A, P1<B>> {
public P1<B> f(final A a) {
return null;
}
}
}
class P1<T> {
}
@@ -148,6 +148,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA89771() throws Exception { doTest(false); }
public void testIDEA89801() throws Exception { doTest(false); }
public void testInconvertibleTypes() throws Exception { doTest(false); }
public void testIncompatibleReturnType() throws Exception { doTest(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));