8230827: javac gives inappropriate warning about potentially ambiguous methods
Fix of too strict com.sun.tools.javac.comp.Comp:checkPotentiallyAmbiguousOverloads method Reviewed-by: jlahoda
This commit is contained in:
parent
7671f2716b
commit
456fe234ce
@ -2686,7 +2686,7 @@ public class Check {
|
||||
types.findDescriptorType(t).getParameterTypes().length()) {
|
||||
potentiallyAmbiguous = true;
|
||||
} else {
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
args1 = args1.tail;
|
||||
|
45
test/langtools/tools/javac/8230827/T8230827.java
Normal file
45
test/langtools/tools/javac/8230827/T8230827.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8230827
|
||||
* @summary javac gives inappropriate warning about potentially ambiguous methods
|
||||
* @compile/fail/ref=T8230827.out -XDrawDiagnostics -Xlint:all -Werror T8230827.java
|
||||
*/
|
||||
|
||||
class T8230827 {
|
||||
interface I1 {
|
||||
void m1(int i);
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
void m2(boolean b);
|
||||
}
|
||||
|
||||
public void nonambiguousMethod1(Boolean differentParam, I1 ambiguousInterface) {}
|
||||
|
||||
public void nonambiguousMethod1(String differentParam, I2 ambiguousInterface) {}
|
||||
|
||||
|
||||
public void nonambiguousMethod2(Object ambiguousParam, I1 ambiguousInterface, String differentParam) {}
|
||||
|
||||
public void nonambiguousMethod2(Object ambiguousParam, I2 ambiguousInterface, Boolean differentParam) {}
|
||||
|
||||
|
||||
public void ambiguousMethod1(Object ambiguousParam, I1 ambiguousInterface) {}
|
||||
|
||||
public void ambiguousMethod1(Object ambiguousParam, I2 ambiguousInterface) {}
|
||||
|
||||
|
||||
public void ambiguousMethod2(I1 ambiguousInterface, Object ambiguousParam) {}
|
||||
|
||||
public void ambiguousMethod2(I2 ambiguousInterface, Object ambiguousParam) {}
|
||||
|
||||
|
||||
public void ambiguousMethod3(I1 ambiguousInterface, I1 sameInterface) {}
|
||||
|
||||
public void ambiguousMethod3(I2 ambiguousInterface, I1 sameInterface) {}
|
||||
|
||||
|
||||
public void ambiguousMethod4(Object ambiguousParent, I1 ambiguousInterface, String ambiguousChild) {}
|
||||
|
||||
public void ambiguousMethod4(String ambiguousChild, I2 ambiguousInterface, Object ambiguousParent) {}
|
||||
}
|
7
test/langtools/tools/javac/8230827/T8230827.out
Normal file
7
test/langtools/tools/javac/8230827/T8230827.out
Normal file
@ -0,0 +1,7 @@
|
||||
T8230827.java:27:17: compiler.warn.potentially.ambiguous.overload: ambiguousMethod1(java.lang.Object,T8230827.I1), T8230827, ambiguousMethod1(java.lang.Object,T8230827.I2), T8230827
|
||||
T8230827.java:32:17: compiler.warn.potentially.ambiguous.overload: ambiguousMethod2(T8230827.I1,java.lang.Object), T8230827, ambiguousMethod2(T8230827.I2,java.lang.Object), T8230827
|
||||
T8230827.java:37:17: compiler.warn.potentially.ambiguous.overload: ambiguousMethod3(T8230827.I1,T8230827.I1), T8230827, ambiguousMethod3(T8230827.I2,T8230827.I1), T8230827
|
||||
T8230827.java:42:17: compiler.warn.potentially.ambiguous.overload: ambiguousMethod4(java.lang.Object,T8230827.I1,java.lang.String), T8230827, ambiguousMethod4(java.lang.String,T8230827.I2,java.lang.Object), T8230827
|
||||
- compiler.err.warnings.and.werror
|
||||
1 error
|
||||
4 warnings
|
Loading…
Reference in New Issue
Block a user