diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java index 406efc451e3d..f93f67b83582 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibility.java @@ -15,3 +15,27 @@ abstract class Foo> { return t.field; } } + +public class Bug { + // Idea incorrectly analyses this code with JDK 7 + public void doit(T other) { + // Oops, was legal with JDK 6, no longer legal with JDK 7 + other.mPrivate(); + // Redundant with JDK 6, not a redundant cast with JDK 7 + ((Bug)other).mPrivate(); + } + + // Idea correctly analyses this code + public void doit2(SubClass other) { + // Not legal with JDK 6 or 7 + other.mPrivate(); + // Not redundant with JDK 6 or 7 + ((Bug)other).mPrivate(); + } + + private void mPrivate() { + } +} + +class SubClass extends Bug { +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java index ce2e57ded675..df04ee7de906 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeParameterBoundVisibilityJdk14.java @@ -6,4 +6,28 @@ class A { System.out.println(t.value); } } +} + +public class Bug { + // Idea incorrectly analyses this code with JDK 7 + public void doit(T other) { + // Oops, was legal with JDK 6, no longer legal with JDK 7 + other.mPrivate(); + // Redundant with JDK 6, not a redundant cast with JDK 7 + ((Bug)other).mPrivate(); + } + + // Idea correctly analyses this code + public void doit2(SubClass other) { + // Not legal with JDK 6 or 7 + other.mPrivate(); + // Not redundant with JDK 6 or 7 + ((Bug)other).mPrivate(); + } + + private void mPrivate() { + } +} + +class SubClass extends Bug { } \ No newline at end of file