new inference: erasure of type parameters with proper bounds (IDEA-162544)
authorAnna.Kozlova <anna.kozlova@jetbrains.com>
Wed, 19 Oct 2016 17:16:04 +0000 (19:16 +0200)
committerAnna.Kozlova <anna.kozlova@jetbrains.com>
Wed, 19 Oct 2016 17:17:33 +0000 (19:17 +0200)
java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting8/UncheckedWarningsInsideIncorporationPhase.java

index 633a5e5b6e31fbd5e9e63752e260eceff8255c9b..3a4e80bda6dcc1c443d3d72a62f22586bd48cedc 100644 (file)
@@ -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 (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;
               mySession.setErased();
             }
             continue;
index 0d3c34cd90e73bfe707dd84b174f05914d08e416..51eb5129a1f34fb4dd22a9d076ff919bb115d956 100644 (file)
@@ -8,6 +8,12 @@ abstract class Group {
   }
 
   public abstract <R extends Category<R>> R getCategory(Key<R> key);
   }
 
   public abstract <R extends Category<R>> R getCategory(Key<R> key);
+
+  public <T extends Category> T get1(Key<T> key) {
+    return getCategory1(key);
+  }
+
+  public abstract <R extends Category> R getCategory1(Key<R> key);
 }
 
 interface Category<Tc extends Category> {
 }
 
 interface Category<Tc extends Category> {
@@ -15,3 +21,17 @@ interface Category<Tc extends Category> {
 
 class Key<Tk extends Category> {
 }
 
 class Key<Tk extends Category> {
 }
+
+class Test {
+
+  static <T extends B> T get(T b) {
+    return create(b);
+  }
+
+  public static <K extends A<?, ?>> K create(K a) {
+    return a;
+  }
+}
+
+class A<T, U> {}
+class B<R> extends A<Object, R> {}
\ No newline at end of file