diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java index b21bc6bb3415..5ecdebebed0d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/PsiSubstitutorImpl.java @@ -159,7 +159,7 @@ public class PsiSubstitutorImpl implements PsiSubstitutor { if (newBound instanceof PsiCapturedWildcardType) { final PsiWildcardType wildcard = ((PsiCapturedWildcardType)newBound).getWildcard(); if (wildcardType.isExtends() != wildcard.isExtends()) { - return wildcard.isBounded() ? PsiWildcardType.createUnbounded(wildcardType.getManager()) : newBound; + return wildcard.isBounded() ? wildcard.getBound() : newBound; } if (!wildcard.isBounded()) return PsiWildcardType.createUnbounded(wildcardType.getManager()); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsBoundsIntersection.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsBoundsIntersection.java new file mode 100644 index 000000000000..013657a5ea8e --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/WildcardsBoundsIntersection.java @@ -0,0 +1,15 @@ +class NodeProperty {} + +class NodeType {} +class NumberExpression extends NodeType {} +class Node { + public ValueT get(NodeProperty prop) { + return null; + } +} + +class Main { + public static void main(NodeProperty nval, Node expr) { + int val = expr.get(nval); + } +} \ 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 8bc65e0cb36d..54f69672b856 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -205,6 +205,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testInstanceClassInStaticContextAccess() throws Exception { doTest17Incompatibility(false); } public void testFlattenIntersectionType() throws Exception { doTest17Incompatibility(false); } public void testIDEA97276() throws Exception { doTest17Incompatibility(false); } + public void testWildcardsBoundsIntersection() throws Exception { doTest17Incompatibility(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));