diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index a674ea013098..173ac1533da0 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -175,7 +175,7 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { } break; case SUBTYPE: - if (PsiType.NULL.equals(upperBound)) { + if (PsiType.NULL.equals(upperBound) || TypeConversionUtil.isAssignable(upperBound, type)) { upperBound = type; } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java new file mode 100644 index 000000000000..82a2a68570ad --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithUpperBoundPromotion.java @@ -0,0 +1,30 @@ + +public class NestedGenericGoodCodeIsRed { + + public void main( String[] args ) { + satisfiesAllOf(isPositive(), isEqualTo(10.9)); + satisfiesAllOf(isPositive(), isEqualTo(10)); + + Number num = null; + satisfiesAllOf(isPositive(), isEqualTo(num)); + + this.satisfiesAllOf(isPositive(), isEqualTo(10)); + } + + + public interface Predicate { + + } + + public void satisfiesAllOf( Predicate first, Predicate second ) { + } + + public Predicate isPositive() { + return null; + } + + public Predicate isEqualTo( EQUALTO target ) { + return null; + } + +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index a68ee6bf6d3f..286dd2015d09 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -50,6 +50,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testExplicitMethodParameters1() throws Exception { doTest(false); } public void testInferenceWithBounds() throws Exception {doTest(false);} public void testInferenceWithSuperBounds() throws Exception {doTest(false);} + public void testInferenceWithUpperBoundPromotion() throws Exception {doTest(false);} public void testVariance() throws Exception {doTest(false);} public void testForeachTypes() throws Exception {doTest(false);} public void testRawOverridingMethods() throws Exception {doTest(false);}