diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java index dc092a73346b..699e33476b48 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodCallExpressionImpl.java @@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.tree.java; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; @@ -194,7 +195,13 @@ public class PsiMethodCallExpressionImpl extends ExpressionPsiElement implements if (is15OrHigher) { final PsiSubstitutor substitutor = result.getSubstitutor(); PsiType substitutedReturnType = substitutor.substitute(ret); - if (PsiUtil.isRawSubstitutor(method, substitutor) && ret.equals(substitutedReturnType)) return TypeConversionUtil.erasure(ret); + if (substitutedReturnType == null) return TypeConversionUtil.erasure(ret); + if (PsiUtil.isRawSubstitutor(method, substitutor)) { + final PsiType returnTypeErasure = TypeConversionUtil.erasure(ret); + if (Comparing.equal(TypeConversionUtil.erasure(substitutedReturnType), returnTypeErasure)) { + return returnTypeErasure; + } + } PsiType lowerBound = PsiType.NULL; if (substitutedReturnType instanceof PsiCapturedWildcardType) { lowerBound = ((PsiCapturedWildcardType)substitutedReturnType).getLowerBound(); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodCallOnRawTypesExtended.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodCallOnRawTypesExtended.java new file mode 100644 index 000000000000..4c29f2d1f90a --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/MethodCallOnRawTypesExtended.java @@ -0,0 +1,17 @@ +import java.util.Collections; +import java.util.List; + +class Bar { + private List getChildren(Property property, PropertiesContainer c) { + return property.getChildren(c); + } + + static class PropertiesContainer {} + +} + +class Property { + public List> getChildren(K container) { + return Collections.emptyList(); + } +} \ 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 b238fc0e6915..9ce2daa03861 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -213,6 +213,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { doTest5(false); } + public void testMethodCallOnRawTypesExtended() throws Exception { + doTest5(false); + } + public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); assertNotNull(collectionsClass);