From a40a08d1d955d3d5138595da2dbb4f5cdaced2c2 Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 18 Oct 2012 21:36:03 +0200 Subject: [PATCH] good code red: leave empty subst when processing type params supers (IDEA-67680) --- .../intellij/psi/impl/PsiClassImplUtil.java | 3 ++ .../TypeArgumentsGivenOnRawType.java | 31 +++++++++++++++++++ .../daemon/GenericsHighlightingTest.java | 1 + 3 files changed, 35 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsGivenOnRawType.java diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java index 6992c102574a..6c356bb0573c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiClassImplUtil.java @@ -675,6 +675,9 @@ public class PsiClassImplUtil { if (superClass == null) continue; PsiSubstitutor finalSubstitutor = obtainFinalSubstitutor(superClass, superTypeResolveResult.getSubstitutor(), aClass, state.get(PsiSubstitutor.KEY), factory, languageLevel); + if (aClass instanceof PsiTypeParameter && PsiUtil.isRawSubstitutor(superClass, finalSubstitutor)) { + finalSubstitutor = PsiSubstitutor.EMPTY; + } if (!processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited, last, place, isRaw)) { resolved = true; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsGivenOnRawType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsGivenOnRawType.java new file mode 100644 index 000000000000..9b85d2949260 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsGivenOnRawType.java @@ -0,0 +1,31 @@ +class A { + abstract class C { + void foo(T.C x) { + Integer bar = x.bar(); + } + + void foo1(A.C x) { + Integer bar = x.bar(); + } + + void foo2(A.C x) { + Integer bar = x.bar(); + } + + abstract S bar(); + } +} + +class A1 { + abstract class C { + void foo(T.C x) { + Integer bar = x.bar(); + } + + void foo1(A1.C x) { + Integer bar = x.bar(); + } + + abstract S bar(); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 3ebc98e69a9c..55404d58c1ce 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -151,6 +151,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testIncompatibleReturnType() throws Exception { doTest(false); } public void testContinueInferenceAfterFirstRawResult() throws Exception { doTest(false); } public void testStaticOverride() throws Exception { doTest(false); } + public void testTypeArgumentsGivenOnRawType() throws Exception { doTest(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));