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-67919; IDEA-67863; IDEA-67920; IDEA-67831; IDEA-67833; IDEA-67674; IDEA-67587; IDEA-57646; IDEA-57407; IDEA-57279; IDEA-57296; IDEA-57297; IDEA-57316; IDEA-57331)
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
package pck;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static pck.C.foo;
|
||||
import static pck.D.foo;
|
||||
|
||||
class C {
|
||||
static <T> void foo(List<? extends List<T>> x) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
static <T> String foo(List<List<T>> x) { return null; }
|
||||
}
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
List<List<String>> x = null;
|
||||
foo(x).toLowerCase();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package pck;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static pck.C.foo;
|
||||
import static pck.D.foo;
|
||||
|
||||
class C {
|
||||
static <T> void foo(List<T> x) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
static <T> String foo(List<T[]> x) { return null; }
|
||||
}
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
List<String[]> x = null;
|
||||
foo(x).toLowerCase();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package pck;
|
||||
|
||||
interface A<T>
|
||||
{
|
||||
T foo();
|
||||
}
|
||||
|
||||
interface B<T> extends A<T[]> { }
|
||||
|
||||
class C<T extends A<Object[]> & B<?>>
|
||||
{
|
||||
void foo(T x)
|
||||
{
|
||||
Object[] foo = x.foo();
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pck;
|
||||
|
||||
interface A<T>
|
||||
{
|
||||
T foo();
|
||||
}
|
||||
|
||||
interface B<T extends Cloneable> extends A<T> { }
|
||||
|
||||
class C<T extends A<?> & B<?>>
|
||||
{
|
||||
void bar(T x)
|
||||
{
|
||||
x.foo();
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package pck;
|
||||
|
||||
interface IA<T> {
|
||||
T a();
|
||||
}
|
||||
|
||||
interface IB {
|
||||
String a();
|
||||
}
|
||||
|
||||
abstract class C implements IA<String>, IB {
|
||||
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface IAO {
|
||||
Object a();
|
||||
}
|
||||
|
||||
abstract class CO implements IAO, IB {
|
||||
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pck;
|
||||
|
||||
interface IA<T> {
|
||||
T a();
|
||||
}
|
||||
|
||||
interface IB {
|
||||
String a();
|
||||
}
|
||||
|
||||
abstract class C implements IA<String>, IB {
|
||||
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface IAO {
|
||||
Object a();
|
||||
}
|
||||
|
||||
abstract class CO implements IAO, IB {
|
||||
|
||||
{
|
||||
a();
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package pck;
|
||||
|
||||
class A<T> {}
|
||||
|
||||
interface IA{
|
||||
void foo(A<?> x);
|
||||
}
|
||||
interface IB{
|
||||
<T> void foo(A<T> x);
|
||||
}
|
||||
class C {
|
||||
<T extends IA & IB> void bar(T x, A<String> y){
|
||||
x.foo<error descr="Ambiguous method call: both 'IA.foo(A<?>)' and 'IB.foo(A<String>)' match">(y)</error>;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package pck;
|
||||
|
||||
class A<T> {}
|
||||
|
||||
interface IA{
|
||||
<T> void foo(A<A<T>> x);
|
||||
}
|
||||
interface IB{
|
||||
<T> void foo(A<? super A<T>> x);
|
||||
}
|
||||
class C {
|
||||
<T extends IB & IA> void bar(T x, A<A<String>> 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(b);
|
||||
}
|
||||
|
||||
<T> void bar(B<? extends A<?>> a){}
|
||||
<T> void bar(A<? extends A<T>> a){}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package pck;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static pck.C.foo;
|
||||
import static pck.D.foo;
|
||||
|
||||
class C {
|
||||
static <T> void foo(List<T> x) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
static <T extends List<?>> String foo(List<T> x) { return null; }
|
||||
}
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
List<List<String>> x = null;
|
||||
foo(x).toCharArray();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package pck;
|
||||
import static pck.C.foo;
|
||||
import static pck.D.foo;
|
||||
|
||||
public class C {
|
||||
public static void foo(){}
|
||||
}
|
||||
class D {
|
||||
public static <T> void foo(){}
|
||||
}
|
||||
|
||||
class B {
|
||||
{
|
||||
foo<error descr="Ambiguous method call: both 'C.foo()' and 'D.foo()' match">()</error>;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package pck;
|
||||
import static pck.D.foo;
|
||||
import static pck.C.foo;
|
||||
|
||||
public class C {
|
||||
public static <T> void foo(Comparable<T> x){}
|
||||
}
|
||||
|
||||
class D {
|
||||
public static void foo(Comparable<?> x){}
|
||||
}
|
||||
|
||||
class B{
|
||||
public static void bar(Comparable<?> x){
|
||||
foo<error descr="Ambiguous method call: both 'D.foo(Comparable<?>)' and 'C.foo(Comparable<?>)' match">(x)</error>;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package pck;
|
||||
abstract class A {
|
||||
abstract void foo(Object... x);
|
||||
abstract void foo(int... x);
|
||||
|
||||
{
|
||||
foo<error descr="Ambiguous method call: both 'A.foo(Object...)' and 'A.foo(int...)' match">(1)</error>;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package pck;
|
||||
|
||||
abstract class A {
|
||||
abstract <T> void foo(T... y);
|
||||
abstract <T> void foo(T[]... y);
|
||||
void bar(){
|
||||
foo();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user