diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java index e80063593d53..db598368ce9b 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/JavaClassSupersImpl.java @@ -42,24 +42,22 @@ public class JavaClassSupersImpl extends JavaClassSupers { @NotNull GlobalSearchScope scope, @NotNull PsiSubstitutor derivedSubstitutor) { if (InheritanceImplUtil.hasObjectQualifiedName(superClass)) return PsiSubstitutor.EMPTY; - if (!(derivedClass instanceof PsiTypeParameter)) { - List bounds = null; - if (superClass instanceof InferenceVariable) { - bounds = ((InferenceVariable)superClass).getBounds(InferenceBound.LOWER); + List bounds = null; + if (superClass instanceof InferenceVariable) { + bounds = ((InferenceVariable)superClass).getBounds(InferenceBound.LOWER); + } + else if (superClass instanceof PsiTypeParameter) { + final PsiType lowerBound = superClass.getUserData(InferenceSession.LOWER_BOUND); + if (lowerBound != null) { + bounds = Collections.singletonList(lowerBound); } - else if (superClass instanceof PsiTypeParameter) { - final PsiType lowerBound = superClass.getUserData(InferenceSession.LOWER_BOUND); + } + if (bounds != null) { + for (PsiType lowerBound : bounds) { if (lowerBound != null) { - bounds = Collections.singletonList(lowerBound); - } - } - if (bounds != null) { - for (PsiType lowerBound : bounds) { - if (lowerBound != null) { - final PsiSubstitutor substitutor = processLowerBound(lowerBound, derivedClass, scope, derivedSubstitutor); - if (substitutor != null) { - return substitutor; - } + final PsiSubstitutor substitutor = processLowerBound(lowerBound, derivedClass, scope, derivedSubstitutor); + if (substitutor != null) { + return substitutor; } } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/FreshVariableLowerBoundsDuringSuptypeChecks.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/FreshVariableLowerBoundsDuringSuptypeChecks.java new file mode 100644 index 000000000000..935cf04c6eb4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/FreshVariableLowerBoundsDuringSuptypeChecks.java @@ -0,0 +1,14 @@ +import java.util.List; +import java.util.function.Supplier; + +class Test { + + { + Supplier> s = Test::foo; + } + + static List foo() { + return null; + } +} + diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java index 2451d8280718..5a2a9368959f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java @@ -502,6 +502,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase { doTest(); } + public void testFreshVariableLowerBoundsDuringSuptypeChecks() throws Exception { + doTest(); + } + private void doTest() { doTest(false); }