new overload resolution: covariant comparison of return types

This commit is contained in:
Anna Kozlova
2014-04-22 20:02:33 +02:00
parent 98ab76f060
commit 17b020f7c2
4 changed files with 24 additions and 4 deletions
@@ -1070,7 +1070,7 @@ public class InferenceSession {
session.addConstraint(new StrictSubtypingConstraint(tReturnType, sReturnType));
return true;
} else {
return sReturnType != null && tReturnType != null && TypeConversionUtil.isAssignable(sReturnType, tReturnType);
return sReturnType != null && tReturnType != null && TypeConversionUtil.isAssignable(tReturnType, sReturnType);
}
}
}
@@ -1115,7 +1115,7 @@ public class InferenceSession {
session.addConstraint(new StrictSubtypingConstraint(tReturnType, sReturnType));
return true;
} else {
return sReturnType != null && tReturnType != null && TypeConversionUtil.isAssignable(sReturnType, tReturnType);
return sReturnType != null && tReturnType != null && TypeConversionUtil.isAssignable(tReturnType, sReturnType);
}
}
@@ -624,11 +624,11 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
if (!applicable12ignoreFunctionalType && applicable21ignoreFunctionalType) {
return specifics == Specifics.SECOND ? Specifics.SECOND : Specifics.NEITHER;
return specifics == Specifics.FIRST ? Specifics.FIRST : Specifics.NEITHER;
}
if (!applicable21ignoreFunctionalType && applicable12ignoreFunctionalType) {
return specifics == Specifics.FIRST ? Specifics.FIRST : Specifics.NEITHER;
return specifics == Specifics.SECOND ? Specifics.SECOND : Specifics.NEITHER;
}
return specifics;
@@ -0,0 +1,16 @@
class Test {
interface I { Object invoke(); }
interface IStr { String foo(); }
private static void call(IStr str) {
System.out.println(str);
}
private static void <warning descr="Private method 'call(Test.I)' is never used">call</warning>(I i) {
System.out.println(i);
}
public static void main(String[] args) {
call(()-> null);
}
}
@@ -79,6 +79,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
doTest(false);
}
public void testMostSpecificByReturnType() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}