overload resolution: don't prefer concrete over abstract if the signatures are not override-equivalent

This commit is contained in:
Anna Kozlova
2016-05-27 21:11:11 +03:00
parent 1d57bb658d
commit 2bedb80d81
5 changed files with 58 additions and 17 deletions

View File

@@ -0,0 +1,24 @@
import java.io.IOException;
abstract class Ambiguity {
public abstract <T> T executeServerOperation(ThrowableComputable<T, IOException> computable);
public <T> T executeServerOperation(final Computable<T> computable) {
return null;
}
boolean foo(Ambiguity a, String s){
return a.<error descr="Ambiguous method call: both 'Ambiguity.executeServerOperation(ThrowableComputable<Boolean, IOException>)' and 'Ambiguity.executeServerOperation(Computable<Boolean>)' match">executeServerOperation</error>(() -> bool(s, a));
}
protected abstract boolean bool(String s, Ambiguity a);
}
interface ThrowableComputable<T, E extends Throwable> {
T compute() throws E;
}
interface Computable <T> {
T compute();
}

View File

@@ -39,7 +39,7 @@ class Test2 {
public static void main(IJ s, J<String> j) {
s.f("");
<error descr="Static method may be invoked on containing interface class only">j.j("");</error>
j.j<error descr="Ambiguous method call: both 'J.j(String)' and 'J.j(String)' match">("")</error>;
}
}