From 78e9bb78400005349cb0fcdb0b4076c9f55208fe Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Mon, 5 May 2014 15:54:35 +0400 Subject: [PATCH] type parameters should not cause deprecated constructor warning to appear (IDEA-124689) --- .../codeInspection/deprecation/DeprecationInspection.java | 1 + .../expected.xml | 2 ++ .../src/Test.java | 6 ++++++ .../intellij/codeInspection/DeprecationInspectionTest.java | 4 ++++ 4 files changed, 13 insertions(+) create mode 100644 java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/expected.xml create mode 100644 java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/src/Test.java diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java index 85b3674d520d..a490f81b1d65 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspection.java @@ -189,6 +189,7 @@ public class DeprecationInspection extends BaseJavaBatchLocalInspectionTool { @Override public void visitClass(PsiClass aClass) { + if (aClass instanceof PsiTypeParameter) return; final PsiMethod[] currentConstructors = aClass.getConstructors(); if (currentConstructors.length == 0) { final PsiClass superClass = aClass.getSuperClass(); diff --git a/java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/expected.xml b/java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/expected.xml new file mode 100644 index 000000000000..4704d91e891d --- /dev/null +++ b/java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/expected.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/src/Test.java b/java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/src/Test.java new file mode 100644 index 000000000000..f3f557533910 --- /dev/null +++ b/java/java-tests/testData/inspection/deprecation/DeprecatedDefaultConstructorFromTypeParameter/src/Test.java @@ -0,0 +1,6 @@ +class Test { + @Deprecated + protected Test() { } + + static void foo() {} +} diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java index e3a4f92db573..2cd737e5ed78 100644 --- a/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInspection/DeprecationInspectionTest.java @@ -49,4 +49,8 @@ public class DeprecationInspectionTest extends InspectionTestCase { doTest(); } + public void testDeprecatedDefaultConstructorFromTypeParameter() throws Exception { + doTest(); + } + }