From f26364eca1857c5d6a44eee9290d6653a02c9fbd Mon Sep 17 00:00:00 2001 From: "Anna.Kozlova" Date: Wed, 19 Oct 2016 19:16:04 +0200 Subject: [PATCH] new inference: erasure of type parameters with proper bounds (IDEA-162544) --- .../InferenceIncorporationPhase.java | 2 +- ...eckedWarningsInsideIncorporationPhase.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java index 633a5e5b6e31..3a4e80bda6dc 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java @@ -296,7 +296,7 @@ public class InferenceIncorporationPhase { if (eqBound == null || PsiType.NULL.equals(eqBound) || eqBound instanceof PsiWildcardType) continue; if (Registry.is("javac.unchecked.subtyping.during.incorporation", true)) { if (TypeCompatibilityConstraint.isUncheckedConversion(upperBound, eqBound)) { - if (PsiUtil.resolveClassInType(eqBound) instanceof PsiTypeParameter) { + if (PsiUtil.resolveClassInType(eqBound) instanceof PsiTypeParameter && !mySession.isProperType(upperBound)) { mySession.setErased(); } continue; diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UncheckedWarningsInsideIncorporationPhase.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UncheckedWarningsInsideIncorporationPhase.java index 0d3c34cd90e7..51eb5129a1f3 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UncheckedWarningsInsideIncorporationPhase.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UncheckedWarningsInsideIncorporationPhase.java @@ -8,6 +8,12 @@ abstract class Group { } public abstract > R getCategory(Key key); + + public T get1(Key key) { + return getCategory1(key); + } + + public abstract R getCategory1(Key key); } interface Category { @@ -15,3 +21,17 @@ interface Category { class Key { } + +class Test { + + static T get(T b) { + return create(b); + } + + public static > K create(K a) { + return a; + } +} + +class A {} +class B extends A {} \ No newline at end of file