show error if override generics method in raw inheritor (comment IDEA-19718)

This commit is contained in:
anna
2013-05-07 13:43:26 +02:00
parent 3f6f5b5a9e
commit a9a42e512b
3 changed files with 21 additions and 0 deletions
@@ -548,6 +548,17 @@ public class GenericsHighlightUtil {
for (HierarchicalMethodSignature superSignature : supers) {
info = checkSameErasureNotSubSignatureInner(superSignature, manager, aClass, sameErasureMethods);
if (info != null) return info;
if (superSignature.isRaw() && !signature.isRaw()) {
final PsiType[] parameterTypes = signature.getParameterTypes();
PsiType[] types = superSignature.getParameterTypes();
for (int i = 0; i < types.length; i++) {
if (!Comparing.equal(parameterTypes[i], TypeConversionUtil.erasure(types[i]))) {
return getSameErasureMessage(false, method, superSignature.getMethod(), HighlightNamesUtil.getClassDeclarationTextRange(aClass));
}
}
}
}
return null;
}
@@ -0,0 +1,9 @@
import java.util.List;
<error descr="'method(List<String>)' in 'Implementation' clashes with 'method(List<String>)' in 'IfcWithGenericMethod'; both methods have same erasure, yet neither overrides the other">class Implementation implements IfcWithGenericMethod</error> {
public void method(final List<String> strings) {}
}
interface IfcWithGenericMethod<T> {
void method(List<String> strings);
}
@@ -237,6 +237,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testIDEA57877() throws Exception { doTest5(false);}
public void testCaptureTopLevelWildcardsForConditionalExpression() throws Exception { doTest5(false);}
public void testGenericsOverrideMethodInRawInheritor() throws Exception { doTest5(false);}
public void testIDEA27185(){ doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
public void testIDEA67571(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }