mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
ambiguous method calls: conflict resolver, tests
(IDEA-67832; IDEA-67837; IDEA-67573; IDEA-57306; IDEA-57535; IDEA-57269; IDEA-57278; IDEA-57317)
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
package pck;
|
||||
|
||||
class A {
|
||||
<T> void foo(T x) {
|
||||
foo(1);
|
||||
|
||||
long x1 = 1L;
|
||||
foo(x1);
|
||||
|
||||
Long x2 = 1L;
|
||||
foo(x2);
|
||||
|
||||
Integer x3 = 1;
|
||||
foo(x3);
|
||||
}
|
||||
|
||||
void foo(long x) {
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package pck;
|
||||
|
||||
interface I{
|
||||
<T extends Iterable<String> & Cloneable> void foo();
|
||||
}
|
||||
|
||||
abstract class A {
|
||||
abstract <T extends Iterable<String>> void foo();
|
||||
<T extends A & I> void bar(T x){
|
||||
x.foo<error descr="Ambiguous method call: both 'A.foo()' and 'I.foo()' match">()</error>;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package pck;
|
||||
|
||||
class A<T> {}
|
||||
|
||||
interface IA{
|
||||
<T> void foo(A<T> x);
|
||||
}
|
||||
interface IB{
|
||||
<T extends Exception> void foo(A<T> x);
|
||||
}
|
||||
class C {
|
||||
<<error descr="'foo(A<T>)' in 'pck.IB' clashes with 'foo(A<T>)' in 'pck.IA'; both methods have same erasure, yet neither overrides the other"></error>T extends IA & IB> void bar(T x, A<Exception> y){
|
||||
x.foo(y);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package pck;
|
||||
|
||||
class B<K> {}
|
||||
class A<K> extends B<K> {
|
||||
void foo(A<A<String>> b){
|
||||
bar<error descr="Ambiguous method call: both 'A.bar(B<? extends A<String>>)' and 'A.bar(A<? extends B<String>>)' match">(b)</error>;
|
||||
}
|
||||
|
||||
<T> void bar(B<? extends A<T>> a){}
|
||||
<T> void bar(A<? extends B<T>> a){}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package pck;
|
||||
|
||||
abstract class C{
|
||||
abstract <T extends Comparable<?>> void foo(T x);
|
||||
abstract <T extends Number & Comparable<?>> void foo(T x);
|
||||
void bar(Integer x){
|
||||
foo(x);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
interface A
|
||||
{
|
||||
abstract void foo(String[] ... s);
|
||||
}
|
||||
|
||||
interface B
|
||||
{
|
||||
abstract void foo(String[] s);
|
||||
}
|
||||
|
||||
class C<T extends A & B>
|
||||
{
|
||||
void bar(T x)
|
||||
{
|
||||
x.foo(null);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package pck;
|
||||
import static pck.D.foo;
|
||||
import static pck.C.foo;
|
||||
|
||||
public class C {
|
||||
public static <T extends Comparable<S>, S> void foo(T x){}
|
||||
}
|
||||
|
||||
class D {
|
||||
public static <T extends Comparable<?>> void foo(T x){}
|
||||
}
|
||||
|
||||
class B{
|
||||
{
|
||||
foo<error descr="Ambiguous method call: both 'D.foo(Integer)' and 'C.foo(Integer)' match">(1)</error>;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package pck;
|
||||
|
||||
import static pck.D.foo;
|
||||
import static pck.C.foo;
|
||||
|
||||
public class C {
|
||||
public static <T> void foo(Comparable<? extends Comparable<T>> x){}
|
||||
}
|
||||
|
||||
class D {
|
||||
public static void foo(Comparable<? extends Number> x){}
|
||||
}
|
||||
|
||||
class B{
|
||||
public static void bar(){
|
||||
foo<error descr="Ambiguous method call: both 'D.foo(Comparable<? extends Number>)' and 'C.foo(Comparable<? extends Comparable<Integer>>)' match">(1)</error>;
|
||||
}
|
||||
}
|
||||
@@ -132,4 +132,36 @@ public class AdvHighlightingJdk7Test extends DaemonAnalyzerTestCase {
|
||||
public void testAmbiguousMultipleTypeParamExtends3() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA57317() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA57278() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA57269() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA67573() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA57306() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA57535() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA67832() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
|
||||
public void testAmbiguousIDEA67837() throws Exception {
|
||||
doTestAmbiguous();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user