mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
tests fix
This commit is contained in:
+6
-4
@@ -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:
|
||||
|
||||
+1
-2
@@ -34,7 +34,6 @@ class C {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final TestProcessor testProcessor = new TestProcessor();
|
||||
testProcessor.processMap(<warning descr="Unchecked assignment: 'java.util.HashMap' to 'java.util.Map<java.lang.String,java.lang.String>'">new HashMap()</warning>);
|
||||
// ^^^ to cdr: should resolve to TestProcessor.processMap() (at UncheckedWarningLocalInspection.java:228)
|
||||
testProcessor.processMap(new HashMap());
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class TestClassT {
|
||||
static {
|
||||
new B().<ref>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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
public static interface GenericAgnosticProcessor {
|
||||
void processMap(Map map);
|
||||
}
|
||||
|
||||
public static interface GenericAwareProcessor {
|
||||
void processMap(Map<String, String> 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.<ref>processMap(new HashMap());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user