diff --git a/java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java b/java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
index db990d48f565..bc472252aa6f 100644
--- a/java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
+++ b/java/java-impl/src/com/intellij/psi/scope/conflictResolvers/JavaMethodsConflictResolver.java
@@ -312,10 +312,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
NEITHER
}
- private static Specifics checkSubtyping(PsiType type1, PsiType type2) {
+ private static Specifics checkSubtyping(PsiType type1, PsiType type2, PsiMethod method1, PsiMethod method2) {
boolean noBoxing = type1 instanceof PsiPrimitiveType == type2 instanceof PsiPrimitiveType;
- final boolean assignable2From1 = noBoxing && TypeConversionUtil.isAssignable(type2, type1, false);
- final boolean assignable1From2 = noBoxing && TypeConversionUtil.isAssignable(type1, type2, false);
+ final boolean allowUncheckedConversion =
+ !method1.hasModifierProperty(PsiModifier.STATIC) && !method2.hasModifierProperty(PsiModifier.STATIC);
+ final boolean assignable2From1 = noBoxing && TypeConversionUtil.isAssignable(type2, type1, allowUncheckedConversion);
+ final boolean assignable1From2 = noBoxing && TypeConversionUtil.isAssignable(type1, type2, allowUncheckedConversion);
if (assignable1From2 || assignable2From1) {
if (assignable1From2 && assignable2From1) {
return null;
@@ -407,7 +409,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
PsiType type1 = classSubstitutor1.substitute(methodSubstitutor1.substitute(types1[i]));
PsiType type2 = classSubstitutor2.substitute(methodSubstitutor2.substitute(types2[i]));
- final Specifics specifics = type1 == null || type2 == null ? null : checkSubtyping(type1, type2);
+ final Specifics specifics = type1 == null || type2 == null ? null : checkSubtyping(type1, type2, method1, method2);
if (specifics == null) continue;
switch (specifics) {
case FIRST:
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ErasureClashConfusion.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ErasureClashConfusion.java
index 76d087f3b3b7..e343bf82ef11 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ErasureClashConfusion.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/ErasureClashConfusion.java
@@ -34,7 +34,6 @@ class C {
public static void main(String[] args) {
final TestProcessor testProcessor = new TestProcessor();
- testProcessor.processMap(new HashMap());
- // ^^^ to cdr: should resolve to TestProcessor.processMap() (at UncheckedWarningLocalInspection.java:228)
+ testProcessor.processMap(new HashMap());
}
}
diff --git a/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflictInCaseOfOverride.java b/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflictInCaseOfOverride.java
new file mode 100644
index 000000000000..47eed87e38af
--- /dev/null
+++ b/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflictInCaseOfOverride.java
@@ -0,0 +1,17 @@
+class TestClassT {
+ static {
+ new B().[foo(TestClassT.class);
+ }
+
+ public static class A {
+ public A foo(Class> type) {
+ return new A();
+ }
+ }
+ public static class B extends A {
+ @Override
+ public B foo(Class type) {
+ return new B();
+ }
+ }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflictInCaseOfOverride2.java b/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflictInCaseOfOverride2.java
new file mode 100644
index 000000000000..d92ab9a7b3a3
--- /dev/null
+++ b/java/java-tests/testData/psi/resolve/method/generics/RawVsGenericConflictInCaseOfOverride2.java
@@ -0,0 +1,21 @@
+import java.util.*;
+
+class C {
+ public static interface GenericAgnosticProcessor {
+ void processMap(Map map);
+ }
+
+ public static interface GenericAwareProcessor {
+ void processMap(Map map);
+ }
+
+ public static class TestProcessor implements GenericAwareProcessor, GenericAgnosticProcessor {
+ @Override
+ public void processMap(Map map) { }
+ }
+
+ public static void main(String[] args) {
+ final TestProcessor testProcessor = new TestProcessor();
+ testProcessor.][processMap(new HashMap());
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java
index 2912f4694112..a2534061db84 100644
--- a/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java
+++ b/java/java-tests/testSrc/com/intellij/psi/resolve/ResolveMethod15Test.java
@@ -465,7 +465,7 @@ public class ResolveMethod15Test extends Resolve15TestCase {
}
- private static void assertGenericResolve(PsiReference ref, final String methodName, final String[] expectedTypeParameterValues, final String expectedCallType) {
+ private static void assertGenericResolve(PsiReference ref, final String methodName, final String[] expectedTypeParameterValues, @NonNls final String expectedCallType) {
PsiElement target = ref.resolve();
assertThat(target, instanceOf(PsiMethod.class));
@@ -509,6 +509,18 @@ public class ResolveMethod15Test extends Resolve15TestCase {
assertResolvesToMethodInClass(result, "A");
}
+ public void testRawVsGenericConflictInCaseOfOverride() throws Exception{
+ PsiJavaReference ref = (PsiJavaReference) configureByFile();
+ final JavaResolveResult result = ref.advancedResolve(true);
+ assertResolvesToMethodInClass(result, "B");
+ }
+
+ public void testRawVsGenericConflictInCaseOfOverride2() throws Exception{
+ PsiJavaReference ref = (PsiJavaReference) configureByFile();
+ final JavaResolveResult result = ref.advancedResolve(true);
+ assertResolvesToMethodInClass(result, "TestProcessor");
+ }
+
public void testAutoboxingAndWidening() throws Exception{
PsiJavaReference ref = (PsiJavaReference) configureByFile();
final JavaResolveResult result = ref.advancedResolve(true);
]