mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
good code red: do not apply the same substitutor twice - lead to problems when params depend recursively (IDEA-91866)
This commit is contained in:
+3
-3
@@ -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;
|
||||
|
||||
+20
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user