From fcd09e4b9953a418f90299cfc02067a7fd43807b Mon Sep 17 00:00:00 2001 From: anna Date: Fri, 1 Mar 2013 18:52:55 +0100 Subject: [PATCH] reject type args for constructor of a class without type params (IDEA-102239) --- .../impl/analysis/GenericsHighlightUtil.java | 1 + .../RejectedTypeParamsForConstructor.java | 22 +++++++++++++++++++ .../daemon/LightAdvHighlightingJdk7Test.java | 4 ++++ 3 files changed, 27 insertions(+) create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/RejectedTypeParamsForConstructor.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index ebd37010a2aa..cefa4f40bc26 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -150,6 +150,7 @@ public class GenericsHighlightUtil { final String description; if (targetParametersNum == 0) { if (PsiTreeUtil.getParentOfType(referenceParameterList, PsiCall.class) != null && + typeParameterListOwner instanceof PsiMethod && JavaVersionService.getInstance().isAtLeast(referenceParameterList, JavaSdkVersion.JDK_1_7)) { description = null; } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/RejectedTypeParamsForConstructor.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/RejectedTypeParamsForConstructor.java new file mode 100644 index 000000000000..cfa0d5f15dbd --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/RejectedTypeParamsForConstructor.java @@ -0,0 +1,22 @@ +class Foo { + { + Foo f = new Foo(); + Foo.foo(); + } + + static void foo() {} +} + +class Bar { + Bar() {} + { + Bar b = new Bar(); + } +} + +class Baz { + Baz() {} + { + Baz b = new Baz(); + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index 4b90e72ccf81..6e4b1e817c18 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -167,4 +167,8 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase { public void testAmbiguousMethodCallIDEA97983() throws Exception { doTest(false, false); } public void testAmbiguousMethodCallIDEA100314() throws Exception { doTest(false, false); } public void testInstanceMemberNotAccessibleInStaticContext() throws Exception { doTest(false, false); } + + public void testRejectedTypeParamsForConstructor() throws Exception { + doTest(false, false); + } }