new inference: initial tests

This commit is contained in:
Anna Kozlova
2013-09-20 12:11:57 +04:00
parent 970a180902
commit 935cdbaf3b
229 changed files with 7713 additions and 1 deletions
@@ -0,0 +1,22 @@
public class CssPropertyValueImpl extends CssTableValueBase<CssPropertyValue, Object> implements CssPropertyValue {
public CssPropertyValueImpl(final Type type) {
super(type);
}
}
public abstract class CssTableValueBase<V extends CssTableValue, T> implements CssTableValue<V, T> {
protected CssTableValueBase(final Type type) {
}
protected CssTableValueBase(final T value) {
}
}
enum Type {}
interface CssTableValue<A, B> {
}
interface CssPropertyValue extends CssTableValue<CssPropertyValue, Object> {
}
@@ -0,0 +1,9 @@
@Deprecated @SuppressWarnings("")
<error descr="Class 'Foo' must either be declared abstract or implement abstract method 'run()' in 'Runnable'">public class Foo implements Runnable</error> {
}
class F {
@Deprecated @SuppressWarnings("") <error descr="'f()' is already defined in 'F'">void f()</error> {}
@Deprecated @SuppressWarnings("") <error descr="'f()' is already defined in 'F'">void f()</error> {}
}
@@ -0,0 +1,69 @@
public class Autoboxing {
public boolean compare(short s, Integer i) {
return i == s; //OK, i is unboxed
}
public boolean compare(Short s, Integer i) {
return <error descr="Operator '==' cannot be applied to 'java.lang.Integer', 'java.lang.Short'">i == s</error>; //comparing as references
}
void f(Integer i) {
switch(i) {
default:
}
}
{
Object data = 1;
boolean is1 = <error descr="Operator '==' cannot be applied to 'java.lang.Object', 'int'">data == 1</error>;
}
//IDEADEV-5549: Short and double are convertible
public static double f () {
Short s = 0;
return (double)s;
}
//IDEADEV-5613
class DumbTest {
private long eventId;
public int hashCode() {
return ((Long) eventId).hashCode();
}
}
public static void main(String[] args) {
Long l = 0L;
Short s = 0;
int d = <error descr="Inconvertible types; cannot cast 'java.lang.Long' to 'int'">(int)l</error>;
d = (int)s;
short t = 0;
Integer d1 = <error descr="Inconvertible types; cannot cast 'short' to 'java.lang.Integer'">(Integer) t</error>;
Byte b = <error descr="Inconvertible types; cannot cast 'short' to 'java.lang.Byte'">(Byte) t</error>;
}
{
{
boolean cond = true;
// test for JLS3 bug, see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6888770
Byte B = 0;
byte b = 0;
byte value = cond ? B : b; /////////
short s = 0;
Short S = 0;
short rs = cond ? S : s;
char c = 0;
Character C = 0;
char rc = cond ? C : c;
boolean bb = cond ? Boolean.FALSE : true;
}
}
}
@@ -0,0 +1,13 @@
public class Test {
public Test(Object a) {
}
public Test(int i) {
this(new Integer(i));
}
public Test(long l) {
this(new Long(l));
}
}
@@ -0,0 +1,44 @@
public class Autoboxing {
void method(int i) {
System.out.println("i = " + i);
}
void method(Integer integer) {
System.out.println("integer = " + integer);
}
void m1(Integer integer) { }
void m2(int i) { }
{
method(10);
method(new Integer(10));
m1(10);
m1(new Integer(10));
m2(10);
m2(new Integer(10));
}
}
public class Autoboxing1 {
void method(String s, int i) {
System.out.println("i = " + i);
}
void method(String s, Object o) {
System.out.println("integer = " + o);
}
{
method("abc", new Integer(10));
method("abc", 10);
}
}
class BoxingConflict {
public static void main(String[] args) {
add<error descr="Ambiguous method call: both 'BoxingConflict.add(long, Long)' and 'BoxingConflict.add(Long, Long)' match">(0L, 0L)</error>;
}
public static void add(long k, Long v) { }
public static void add(Long k, Long v) { }
}
@@ -0,0 +1,12 @@
public class Main {
public <T> T getAttribute() {return null;}
public <T> T getAttribute(T def) {return null;}
{
if (getAttribute()) {}
while (getAttribute()) {}
do {} while (getAttribute());
for(int i = 0; getAttribute(); i++);
}
}
@@ -0,0 +1,7 @@
import java.util.*;
abstract class A {
void computeCostIfNeeded(Map<Object, Integer> costMap) {
Math.min(costMap.get(null), 1);
}
}
@@ -0,0 +1,6 @@
import java.util.*;
class Bug {
void foo(Double d) {
List<Class<?>> list = Arrays.asList(d == null ? Object.class : d.getClass());
}
}
@@ -0,0 +1,8 @@
import java.util.Collection;
class Foo {
private void test() {
Object x = null;
((java.util.Collection<?>)x).add<error descr="'add(capture<?>)' in 'java.util.Collection' cannot be applied to '(java.lang.String)'">("")</error>;
}
}
@@ -0,0 +1,39 @@
/*
* 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.
*/
import java.util.*;
public class Test {
public static void bar() {
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends java.util.Iterator>>', required: 'java.lang.Class<? extends java.util.Iterator<?>>'">Class<? extends Iterator<?>> c = foo();</error>
}
public static Class<? extends Iterator> foo() {
return null;
}
}
class Example {
static List<? extends AbstractTreeNode> treeNodes = null;
public static void main(String[] args) {
for (AbstractTreeNode<String> treeNode : treeNodes) {
}
}
}
class AbstractTreeNode<T> {}
@@ -0,0 +1,122 @@
class D implements I<I>{
}
class DT<T> implements I<T>{
}
interface I <T> {
}
<error descr="'I' cannot be inherited with different type arguments: 'I' and 'D'">class CCC extends D implements I<D></error> {
}
abstract class CCC2<T> extends DT<T> implements I<T> {
}
class a extends b<d, c> implements c<d, c<c,c>>, d<b<c<c,c>,d>> {}
public class b<K,V> implements c<K, c<V,V>> { }
interface c<K,V> extends d<b<V,K>> {}
interface d<K> {}
// extending final classes in bounds
class C<T extends String> {
<E extends Integer> void f() {}
}
class GenericExtendItself<T, U extends T>
{
GenericExtendItself<Object,Object> foo;
}
////////////////////
public abstract class ZZZZ<E> {
public abstract E getElement();
}
abstract class Z<E> extends ZZZZ<E> {}
class Z2 extends Z<Integer> {
public Integer getElement() {
return null;
}
}
/////////////////
class BaseC <E> {
E remove(){
return null;
}
}
class DerivedC extends BaseC<String> {
public String remove() {
String s = super.remove();
return null;
}
}
/// raw in the multiple supers
interface Int<T> {
AClass<T> f();
}
abstract class AClass<T> implements Int<T> {
public abstract AClass<T> f();
}
class MyClass extends AClass implements Int{
public AClass f() {
return null;
}
}
class A<T>{
A(){}
A(T t){}
{
new A<A>(new A()){};
}
}
//IDEADEV-4733: this overriding is OK
class Outer<T>
{
public class Inner
{
private final T t;
public Inner(T t) { this.t = t; }
public T getT() { return t; }
public String toString() { return t.toString(); }
}
}
class Other extends Outer<String>
{
public class Ither extends Outer<String>.Inner
{
public Ither()
{
super("hello"); //valid super constructor call
}
}
}
//end of //IDEADEV-4733
interface AI {
}
interface BI {
}
abstract class AbstractClass<T> {
AbstractClass(Class<T> clazz) {
}
}
class ConcreteClass extends AbstractClass<AI> {
ConcreteClass() {
super(AI.class);
}
class InnerClass extends AbstractClass<BI> {
InnerClass() {
super(BI.class); //
}
}
}
///////////////////////
@@ -0,0 +1,21 @@
import java.util.TreeMap;
import java.util.HashMap;
import java.util.Map;
class Test {
boolean f () {
return false;
}
Boolean g (int i) {
//This is OK thanks to boxing f()
return i > 0 ? f () : null;
}
{
Object values = new Object();
//IDEADEV-1756: this should be OK
final Map<Object,Object> newValues = true ? new TreeMap<Object,Object>() : new HashMap<Object,Object>();
newValues.get(values);
}
}
@@ -0,0 +1,23 @@
import java.util.*;
class Test {
List<String> getList(Function<Object, String> function) {
/*
* When the first argument below is a raw type it turns red because IDEA thinks the return
* type is Collection<>. javac and Eclipse don't care
*/
return transform(new ArrayList(), new ArrayList<String>(), function);
}
<R, S, T extends Collection<S>> T transform(Iterable<? extends R> oldCollection, T newCollection, Function<R, S> function) {
for (R r : oldCollection) {
newCollection.add(function.apply(r));
}
return newCollection;
}
interface Function<X, Y> {
Y apply(X input);
}
}
@@ -0,0 +1,90 @@
import java.util.Collection;
import java.util.ArrayList;
interface YO<<warning descr="Type parameter 'T' is never used">T</warning>> {}
interface YO1 extends YO<String> {}
interface YO2 extends YO<Integer> {}
public class ConvertibleTest {
YO2 bar (YO1 s) {
return <error descr="Inconvertible types; cannot cast 'YO1' to 'YO2'">(YO2) s</error>;
}
}
//IDEA-1097
interface Interface1 {}
interface Interface2 {}
class Implementation implements Interface1 {}
public class InconvertibleTypesTest <E extends Interface2>
{
E thing;
public E getThing() {
return thing;
}
Implementation foo(InconvertibleTypesTest<? extends Interface1> i2) {
//This is a valid cast from intersection type
return (Implementation) i2.getThing();
}
}
class MyCollection extends ArrayList<Integer> {}
class Tester {
Collection<String> x(MyCollection l) {
return <error descr="Inconvertible types; cannot cast 'MyCollection' to 'java.util.Collection<java.lang.String>'">(Collection<String>) l</error>;
}
}
class IDEADEV3978 {
class Constructor<T> {
Class<T> getDeclaringClass() {
return null;
}
}
public static void foo(Constructor<?> constructor) {
if(constructor.getDeclaringClass() == String.class) { //captured wildcard is convertible
System.out.println("yep");
}
}
}
class C2<T> {
void f(T t) {
if (t instanceof Object[]) return;
}
}
class Casting {
void f(Object o)
{
if (o instanceof int[]) return;
Object obj1 = (Object)true; f(obj1);
Object ob = (Number)1; f(ob);
Object ob2 = (Object)1; f(ob2);
}
public static <T> T convert(Class<T> clazz, Object obj) {
if (obj == null) return null;
if (String[].class == clazz)
return <warning descr="Unchecked cast: 'java.lang.String[]' to 'T'">(T) parseArray(obj)</warning>;
return null;
}
private static String[] parseArray(Object obj) {
return obj.toString().split(",");
}
}
class CastPrimitiveToTypeParam<T> {
T foo() {
return <error descr="Inconvertible types; cannot cast 'int' to 'T'">(T)1</error>;
}
}
@@ -0,0 +1,21 @@
class W {
Object f() {
return 0;
}
}
class WW extends W {
String f() {
return null;
}
}
interface IQ {
void f();
}
<error descr="'f()' in 'WW' clashes with 'f()' in 'IQ'; attempting to use incompatible return type">class WWW extends WW implements IQ</error> {
}
@@ -0,0 +1,28 @@
import java.util.*;
class Nav {
interface Sized {}
interface Stream<<warning descr="Type parameter 'T' is never used">T</warning>> { }
private static<U, T extends Sized & Iterable<U>> Stream<U> stream(T entity, int flags) {
System.out.println(entity);
System.out.println(flags);
return null;
}
private static<U, T extends Iterable<U>> Stream<U> <warning descr="Private method 'stream(T, int)' is never used">stream</warning>(T entity, int flags) {
System.out.println(entity);
System.out.println(flags);
return null;
}
static class A<T> implements Iterable<T>, Sized {
public Iterator<T> iterator() {
return null;
}
}
public static void main(String[] args) {
Stream<String> aStream = stream(new A<String>(), 0);
System.out.println(aStream);
}
}
@@ -0,0 +1,32 @@
import java.util.List;
public class Test {
interface P {
}
public abstract class AP implements P {
}
public class AP1 extends AP {
}
public class AP2 extends AP {
}
private static final List<Class<AP1>> AP_LIST = listOf(AP1.class);
private static <T> List<T> listOf(T... ts) {
return null;
}
public static void test() {
List<Class<? extends AP>> apList1 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.lang.Class<Test.AP1>>' to 'java.util.List<java.lang.Class<? extends Test.AP>>'">(List<Class<? extends AP>>) AP_LIST</error>;
List<Class<? super AP1>> apList2 = <error descr="Inconvertible types; cannot cast 'java.util.List<java.lang.Class<Test.AP1>>' to 'java.util.List<java.lang.Class<? super Test.AP1>>'">(List<Class<? super AP1>>) AP_LIST</error>;
}
}
@@ -0,0 +1,15 @@
import java.util.Comparator;
public class Main2 {
static class OfRef<T> {
public OfRef() {
this((Comparator<? super T>) naturalOrder());
}
public OfRef(Comparator<? super T> comparator) {
}
static <K extends Comparable<? super K>> Comparator<K> naturalOrder() {
return null;
}
}
}
@@ -0,0 +1,17 @@
import java.util.*;
class Test {
interface Condition<K> {}
class IOC<M> implements Condition {}
static <T> List<T> filter(T[] c, Condition<? super T> con) {
return null;
}
interface OE {}
interface LOE extends OE {}
void foo(OE[] es, IOC<LOE> con) {
List<LOE> l = filter(es, con);
}
}
@@ -0,0 +1,205 @@
enum Operation {
X;
static int s = 0;
public static final String constS = "";
Operation() {
int i = <error descr="It is illegal to access static member 's' from enum constructor or instance initializer">Operation.s</error>;
i = <error descr="It is illegal to access static member 's' from enum constructor or instance initializer">s</error>;
<error descr="It is illegal to access static member 's' from enum constructor or instance initializer">s</error> = 0;
final int x = Integer.MAX_VALUE;
String co = constS;
// TODO: unclear
//Operation o = X;
}
static {
int i = Operation.s;
i = s;
s = 0;
final int x = Integer.MAX_VALUE;
String co = constS;
// TODO: unclear
//Operation o = X;
}
{
int i = <error descr="It is illegal to access static member 's' from enum constructor or instance initializer">Operation.s</error>;
i = <error descr="It is illegal to access static member 's' from enum constructor or instance initializer">s</error>;
<error descr="It is illegal to access static member 's' from enum constructor or instance initializer">s</error> = 0;
final int x = Integer.MAX_VALUE;
String co = constS;
// TODO: unclear
//Operation o = X;
Operation ooo = <error descr="Enum types cannot be instantiated">new Operation()</error>;
}
<error descr="'values()' is already defined in 'Operation'">void values()</error> {}
void values(int i) {}
void valueOf() {}
<error descr="'valueOf(String)' is already defined in 'Operation'">void valueOf(String s)</error> {}
}
class exte extends <error descr="Cannot inherit from final 'Operation'">Operation</error> {
}
class use {
void f(Operation op) {
switch(op) {
case <error descr="An enum switch case label must be the unqualified name of an enumeration constant">Operation.X</error>: break;
}
switch(op) {
case X: break;
}
switch(op) {
case <error descr="Duplicate label 'X'">X</error>: break;
case <error descr="Duplicate label 'X'">X</error>: break;
}
}
}
enum pubCtr {
X(1);
<error descr="Modifier 'public' not allowed here">public</error> pubCtr(int i) {}
}
enum protCtr {
X(1);
<error descr="Modifier 'protected' not allowed here">protected</error> protCtr(int i) {}
}
<error descr="Modifier 'final' not allowed here">final</error> enum Fin { Y }
<error descr="Modifier 'abstract' not allowed here">abstract</error> enum Abstr { }
enum params<error descr="Enum may not have type parameters"><T></error> {
}
enum OurEnum {
A, B, C;
OurEnum() {
}
{
Enum<OurEnum> a = <error descr="It is illegal to access static member 'A' from enum constructor or instance initializer">A</error>;
OurEnum enumValue = <error descr="It is illegal to access static member 'B' from enum constructor or instance initializer">B</error>;
switch (enumValue) {
}
switch (enumValue) {
case A:
break;
}
}
}
enum TestEnum
{
A(<error descr="Illegal forward reference">B</error>), B(A);
TestEnum(TestEnum other) {
<error descr="Call to super is not allowed in enum constructor">super(null, 0)</error>;
}
}
<error descr="Class 'abstr' must either be declared abstract or implement abstract method 'run()' in 'Runnable'">enum abstr implements Runnable</error> {
}
//this one is OK, enum constants are checked instead of enum itself
enum abstr1 implements Runnable {
A {
public void run() {}
};
}
class X extends <error descr="Classes cannot directly extend 'java.lang.Enum'">Enum</error> {
public X(String name, int ordinal) {
super(name, ordinal);
}
}
enum StaticInEnumConstantInitializer {
AN {
<error descr="Inner classes cannot have static declarations"><error descr="Modifier 'static' not allowed here">static</error></error> class s { }
private <error descr="Inner classes cannot have static declarations">static</error> final String t = String.valueOf(1);
};
}
interface Barz {
void baz();
}
enum Fooz implements Barz {
<error descr="Class 'Fooz' must implement abstract method 'baz()' in 'Barz'">FOO</error>;
}
///////////////////////
class sss {
void f() {
<error descr="Enum must not be local">enum EEEE</error> { EE, YY };
}
}
//////////////////////
//This code is OK
enum PowerOfTen {
ONE(1),TEN(10),
HUNDRED(100) {
public String toString() {
return Integer.toString(super.val);
}
};
private final int val;
PowerOfTen(int val) {
this.val = val;
}
public String toString() {
return name().toLowerCase();
}
public static void main(String[] args) {
System.out.println(ONE + " " + TEN + " " + HUNDRED);
}
}
//IDEADEV-8192
enum MyEnum {
X1, X2;
private static MyEnum[] values = values();
public static void test() {
for (MyEnum e : values) { // values is colored red
e.toString();
}
}
}
//end of IDEADEV-8192
class EnumBugIDEADEV15333 {
public enum Type { one, to }
Type type = Type.one;
public void main() {
switch(type){
case one:
Object one = new Object();
}
}
}
class NestedEnums {
enum E1 { }
class C2 {
<error descr="Inner classes cannot have static declarations">enum E2</error> { }
}
static class C3 {
enum E3 { }
}
{
new C3() {
<error descr="Inner classes cannot have static declarations">enum E2</error> { }
};
}
}
@@ -0,0 +1,34 @@
enum IDEA56239 {
A, B() {
{
System.out.println(<error descr="It is illegal to access static member 'A' from enum constructor or instance initializer">A</error>);
System.out.println(<error descr="It is illegal to access static member 'FOO' from enum constructor or instance initializer">FOO</error>);
System.out.println(FOO1);
System.out.println(<error descr="It is illegal to access static member 'C' from enum constructor or instance initializer">C</error>);
}
}, C(<error descr="Illegal forward reference">D</error>), D;
public static String FOO = "";
public static final String FOO1 = "";
IDEA56239() {
}
IDEA56239(IDEA56239 t) {
System.out.println(<error descr="It is illegal to access static member 'A' from enum constructor or instance initializer">A</error>);
System.out.println(<error descr="It is illegal to access static member 'FOO' from enum constructor or instance initializer">FOO</error>);
System.out.println(FOO1);
}
{
System.out.println(<error descr="It is illegal to access static member 'A' from enum constructor or instance initializer">A</error>);
System.out.println(<error descr="It is illegal to access static member 'FOO' from enum constructor or instance initializer">FOO</error>);
System.out.println(FOO1);
}
void foo() {
System.out.println(A);
System.out.println(FOO);
System.out.println(FOO1);
}
}
@@ -0,0 +1,24 @@
<error descr="Modifier 'abstract' not allowed here">abstract</error> enum OurEnum {
<error descr="Class 'Anonymous class derived from OurEnum' must implement abstract method 'foo()' in 'OurEnum'">A</error> {
},
<error descr="'OurEnum' is abstract; cannot be instantiated">B</error>,
C {
void foo() {}
}
;
abstract void foo();
}
enum xxx {
<error descr="'xxx' is abstract; cannot be instantiated">X</error>,
<error descr="Class 'Anonymous class derived from xxx' must implement abstract method 'f()' in 'xxx'">Y</error> {
};
abstract void f();
}
enum ok {
X { void f() {} };
abstract void f();
}
@@ -0,0 +1,9 @@
interface Foo<T> {
public <A extends T, B extends A> void bar(Class<A> key, B value);
}
class FooImpl implements Foo<String>{
public <A extends String, B extends A> void bar(Class<A> key, B value) {
}
}
@@ -0,0 +1,23 @@
class C <T extends Exception> {
void foo () throws T {}
void bar () {
<error descr="Unhandled exception: T">foo ();</error>
}
<T extends Error> void goo() {
try {
int i = 12;
} catch (<error descr="Cannot catch type parameters">T</error> ex) {
}
}
}
//IDEADEV-4169: no problem here
interface Blub {
public <E extends Throwable> void Switch() throws E;
}
class Blib implements Blub {
public <E extends Throwable> void Switch() throws E {
}
}
@@ -0,0 +1,20 @@
import java.util.*;
class Foo {
<T> void foo() {}
<T1 extends List, T2> void foo1() {}
void bar() {}
<T> void xyz(T l) {}
{
foo();
this.<String>foo();
this.<error descr="Wrong number of type arguments: 2; required: 1"><String, Integer></error>foo();
this.<String>bar();
this.<String, Integer>bar();
this.<<error descr="Type parameter 'java.lang.String' is not within its bound; should implement 'java.util.List'">String</error>, Integer>foo1();
this.<String>xyz<error descr="'xyz(java.lang.String)' in 'Foo' cannot be applied to '(java.lang.Integer)'">(Integer.valueOf("27"))</error>;
ArrayList list = new <String>ArrayList<String>();
}
}
@@ -0,0 +1,12 @@
class Test {
public <T> T doStuff() {
return null;
}
public boolean test() {
return doStuff();
}
public Boolean test1() {
return doStuff();
}
}
@@ -0,0 +1,10 @@
import java.util.*;
class C {
static final List EMPTY = new ArrayList(0);
void m() {
List<String> list = C.<error descr="Reference parameters are not allowed here"><String></error>EMPTY;
System.out.println(list);
}
}
@@ -0,0 +1,12 @@
class Test {
public <T> T doStuff() {
return null;
}
public boolean test() {
return doStuff();
}
public Boolean test1() {
return doStuff();
}
}
@@ -0,0 +1,16 @@
interface BusinessEntity<E extends BusinessEntity<E>> {
}
interface EntityId<E extends BusinessEntity> {
E getEntity();
}
public class MyTest {
<T extends BusinessEntity<T>> T getEntity(EntityId<T> defaultValue) {
return getEntityID(defaultValue).getEntity();
}
public <P extends EntityId<?>> P getEntityID(P defaultValue) {
return null;
}
}
@@ -0,0 +1,29 @@
class a {
void f(int[] c) {
for (int i:c) {}
for (<error descr="Incompatible types. Found: 'int', required: 'char'">char i:c</error>) {}
for (double i:c) {}
double[] db = null;
for (<error descr="Incompatible types. Found: 'double', required: 'int'">int i:db</error>) {}
for (double i:db) {}
java.util.List list = null;
for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.String'">String i:list</error>) {}
for (Object o:list) {}
java.util.List<Integer> ct = null;
for (Number n:ct) {}
for (Object n:ct) {}
for (Integer n:ct) {}
for (<error descr="Incompatible types. Found: 'java.lang.Integer', required: 'java.lang.String'">String i:ct</error>) {}
for (<error descr="Incompatible types. Found: 'java.lang.Integer', required: 'java.util.List<java.lang.Integer>'">java.util.List<Integer> i:ct</error>) {}
Object o = null;
for (Object oi: (Iterable)o) {}
for (<error descr="Incompatible types. Found: 'double', required: 'int'">int i:db</error>) {
for (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'int'">int p: list</error>) {}
}
}
}
@@ -0,0 +1,4 @@
class T extends Exception {}
class E<T> extends <error descr="Generic class may not extend 'java.lang.Throwable'">Error</error> {}
class M<T2 extends Exception> extends <error descr="Generic class may not extend 'java.lang.Throwable'">T</error> {}
class Ex<X,Y> extends <error descr="Generic class may not extend 'java.lang.Throwable'">Throwable</error> {}
@@ -0,0 +1,9 @@
import java.util.List;
<error descr="'method(List<String>)' in 'Implementation' clashes with 'method(List<String>)' in 'IfcWithGenericMethod'; both methods have same erasure, yet neither overrides the other">class Implementation implements IfcWithGenericMethod</error> {
public void method(final List<String> strings) {}
}
interface IfcWithGenericMethod<T> {
void method(List<String> strings);
}
@@ -0,0 +1,9 @@
import java.util.*;
public class MyList extends ArrayList {}
public class Test {
public void test() {
List<? super List> list = new ArrayList<List>();
list.add(new MyList());
}
}
@@ -0,0 +1,7 @@
public class TestGenericMap<A extends Comparable<A>, B extends Comparable<B>>
{
public TestGenericMap<B, A> inverse()
{
return new TestGenericMap<>();
}
}
@@ -0,0 +1,13 @@
import java.util.*;
class Test<T> {
public static void foo(<error descr="'Test.this' cannot be referenced from a static context">T</error> t) {}
public void bar(T t) {}
static class A extends ArrayList<<error descr="'Test.this' cannot be referenced from a static context">T</error>> {
static void boo(<error descr="'Test.this' cannot be referenced from a static context">T</error> t){}
}
class B extends ArrayList<T> {
void foo(T r){}
}
}
@@ -0,0 +1,17 @@
import java.util.Collection;
import java.util.Set;
class FooObject<T> {}
class FooId<T extends FooObject> {}
interface Bar {
<T extends FooObject, I extends FooId<? extends T>> T get(I key);
<T extends FooObject, I extends FooId<? extends T>> Collection<T> get(Collection<I> keys);
}
public class Target {
void foo(Bar bar) {
final Set<FooId<?>> keys = null;
final Collection<FooObject> values = bar.get(keys);
}
}
@@ -0,0 +1,10 @@
import java.util.Map;
public class Test {
void bar(Prop p) {
Map<? extends String, ? extends String> map = <error descr="Inconvertible types; cannot cast 'Prop' to 'java.util.Map<? extends java.lang.String,? extends java.lang.String>'">(Map<? extends String, ? extends String>)p</error>;
}
}
abstract class Hashtble<K,V> implements Map<K,V> {}
abstract class Prop extends Hashtble<Object, Object>{}
@@ -0,0 +1,6 @@
class MyClass {
public static void main(Class<? extends MyClass> clazz){
clazz = (Class<? extends MyClass>) clazz.getSuperclass();
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? super capture<? extends MyClass>>>', required: 'java.lang.Class<? extends MyClass>'">clazz = clazz.getSuperclass()</error>;
}
}
@@ -0,0 +1,12 @@
import java.io.Serializable;
public abstract class Test {
abstract <T> T test(Class<T> cls);
abstract <T> T test(Serializable type);
private void call(){
<error descr="Incompatible types. Found: 'java.lang.String[]', required: 'java.lang.String'">String s = test(String[].class);</error>
}
}
@@ -0,0 +1,18 @@
class GoodCodeRed {
static class ClassA {
}
static class Pair<T, N> {
}
<T extends ClassA, M extends T, N extends Number> void max(final M object, Pair<T, N> attribute, final N cnt) {
}
<T extends ClassA, M extends T, N extends String> void max(final M object, Pair<T, N> attribute, final N str) {
}
{
max(new ClassA(), new Pair<ClassA, Integer>(), 1);
}
}
@@ -0,0 +1,3 @@
class X<A extends X<A>> {
static class Y<B extends Y> extends X<<error descr="Type parameter 'B' is not within its bound; should extend 'X<B>'">B</error>> {}
}
@@ -0,0 +1,15 @@
public class Test {
{
final MyResult hello = parseXML(new Parser());
}
public <R, P extends AbstractParser & Result<R>> R parseXML(P parser) {
R result = null;
return result;
}
}
class MyResult {}
class AbstractParser {}
interface Result<T> {}
class Parser extends AbstractParser implements Result {}
@@ -0,0 +1,37 @@
class Test1 {
private static final Foo<Boolean> test = new Foo().method(Boolean.TRUE);
public static void main(String[] args) {
System.out.println(test);
}
public static class Foo<T> {
public Foo<Boolean> method(boolean arg) {
return null;
}
public <T extends Enum<T>> Foo<T> method(T arg) {
return null;
}
}
}
class Test2 {
private static final Foo<Boolean> test = Foo.method(Boolean.TRUE);
public static void main(String[] args) {
System.out.println(test);
}
public static class Foo<T> {
public static Foo<Boolean> method(boolean arg) {
return null;
}
public static <T extends Enum<T>> Foo<T> method(T arg) {
return null;
}
}
}
@@ -0,0 +1,9 @@
class Foo<T> {
static class Nested {};
}
class Bar extends Foo<<error descr="Nested is not accessible in current context">Bar.Nested</error>> {}
interface FooI<T> {
interface Nested {};
}
interface BarI extends FooI<<error descr="Nested is not accessible in current context">BarI.Nested</error>> {}
@@ -0,0 +1,9 @@
class Base { }
class Extended extends Base {}
class Test<T extends Base> {
<T extends Base, U extends T> void test(T x, Class<U> test) {}
{
test(new Extended(), Base.class);
}
}
@@ -0,0 +1,13 @@
import java.util.Collections;
import java.util.Set;
public class Test<Y> {
public static <K> Test<K> doTest(K k){
return null;
}
public static void main(String[] args) {
Test.<Set<String>>doTest<error descr="'doTest(java.util.Set<java.lang.String>)' in 'Test' cannot be applied to '(java.util.Set<java.lang.Object>)'">(Collections.emptySet())</error>;
}
}
@@ -0,0 +1,20 @@
import java.util.Collection;
public class IncorrectError extends NarrowClass {
public Collection<String> bar() {
return super.doStuff();
}
}
interface Interface {
Collection<String> doStuff();
}
class NarrowClass extends BaseClass implements Interface {
}
class BaseClass {
public Collection doStuff() {
return null;
}
}
@@ -0,0 +1,12 @@
class A {
}
abstract class B {
public <T extends A> T getA(Class<T> aClass) {
return null;
}
void foo(Class<?> aClass) {
A a = <error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'A'">getA(aClass)</error>;
}
}
@@ -0,0 +1,17 @@
interface Result {}
interface Command<R extends Result> {}
interface Procedure<C extends Command<Result>> {
}
abstract class ProcedureService {
abstract <C extends Command<Result>> Class<? extends Procedure<Command<Result>>> getProcedure(Class<C> cmd);
public <C extends Command<Result>> void execute(Class<? extends Command> aClass) {
Class<Procedure<Command<Result>>> procedureClass = getProcedure(aClass);
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends Command>>', required: 'java.lang.Class<Command>'">Class<Command> c = aClass;</error>
<error descr="Incompatible types. Found: 'java.lang.Class<capture<? extends Command>>', required: 'java.lang.Class<C>'">Class<C> c1 = aClass;</error>
}
}
@@ -0,0 +1,20 @@
import java.io.*;
import java.util.List;
class Main {
public <T> T foo(String str, Class<T> classOfT) {
return null;
}
public <T> T foo(String str, Serializable typeOfT) {
return null;
}
{
asList(foo("", String[].class));
}
public static <T> List<T> asList(T... a) {
return null;
}
}
@@ -0,0 +1,16 @@
class Cast<T> implements SemElement {
{
final SemKey<? extends Cast> key = null;
final Cast semElement = getSemElement(key);
}
public <T extends SemElement> T getSemElement(SemKey<T> key) {
return null;
}
class SemKey<T extends SemElement> {}
}
interface SemElement {}
@@ -0,0 +1,11 @@
import java.io.Serializable;
public class Test {
public <T extends Serializable> void foo(byte[] data) {
T foo = (T) data;
}
public <T extends Serializable & Runnable> void bar(byte[] data) {
T bar = <error descr="Inconvertible types; cannot cast 'byte[]' to 'T'">(T) data</error>;
}
}
@@ -0,0 +1,15 @@
public abstract class BiFunction<A,B> {
public abstract B apply(A a);
public abstract A unapply(B b);
public BiFunction<B,A> flip() {
return new BiFunction<B, A>() {
public A apply(B b) {
return BiFunction.this.unapply(b);
}
public B unapply(A a) {
return BiFunction.this.apply(a);
}
};
}
}
@@ -0,0 +1,23 @@
import java.util.Collection;
class Test {
public static final UnaryFunction<Object, Object, RuntimeException> unaryFunction = new UnaryFunction<Object, Object, RuntimeException>() {
public Object execute(Object o) throws RuntimeException {
return null;
}
};
public static <A, B, X extends Throwable> void someMethod() {
transformCollection(null, unaryFunction, null);
}
public static <A, B, X extends Throwable> void transformCollection(Collection<? extends A> input, UnaryFunction<A, B, X> transform, Collection<? super B> output) throws X {
for (A a : input) {
B b = transform.execute(a);
output.add(b);
}
}
}
interface UnaryFunction<A, B, X extends Throwable> {
public B execute(A a) throws X;
}
@@ -0,0 +1,26 @@
public class GoodCodeIsRed {
public void test() {
FileIF file = new FileImpl();
file.getInputStream();
}
}
class FileImpl implements FileIF {
public void getInputStream() {
}
}
interface FileIF extends BasicFileIF, DataSource {
}
interface BasicFileIF {
void getInputStream();
}
interface DataSource {
void getInputStream() throws java.io.IOException;
}
@@ -0,0 +1,7 @@
interface Foo<A> {}
interface Bar extends Foo<Boolean> {}
class FooFactory {
public <A> Foo<A> getFoo() {
return (Foo<A>) new Bar() {};
}
}
@@ -0,0 +1,17 @@
import java.util.Collection;
import java.util.Collections;
public class IDEABug {
static class ClassA {
static <T> void sayHello(Collection<? extends T> msg) {}
}
static class ClassB extends ClassA {
<error descr="'sayHello(Collection<? extends T>)' in 'IDEABug.ClassB' clashes with 'sayHello(Collection<? extends T>)' in 'IDEABug.ClassA'; both methods have same erasure, yet neither hides the other">static <T extends String> void sayHello(Collection<? extends T> msg)</error> {}
}
public static void main(String[] args) {
ClassB.sayHello(Collections.<String>emptyList());
}
}
@@ -0,0 +1,17 @@
import java.util.Collection;
import java.util.Collections;
public class IDEABug {
static class ClassA {
static <T> void sayHello(Collection<? extends T> msg) {}
}
static class ClassB extends ClassA {
<error descr="'sayHello(Collection<? extends T>)' in 'IDEABug.ClassB' clashes with 'sayHello(Collection<? extends T>)' in 'IDEABug.ClassA'; both methods have same erasure, yet neither hides the other">static <T extends String> void sayHello(Collection<? extends T> msg)</error> {}
}
public static void main(String[] args) {
ClassB.sayHello(Collections.<String>emptyList());
}
}
@@ -0,0 +1,13 @@
class Test {
interface Foo<T> {
void boo(T t);
}
private static void f(Foo<?>... fs) {
fs[0].boo<error descr="'boo(capture<?>)' in 'Test.Foo' cannot be applied to '(java.lang.String)'">("hey!")</error>;
}
private static void f1(Foo<? extends String>... fs) {
fs[0].boo<error descr="'boo(capture<? extends java.lang.String>)' in 'Test.Foo' cannot be applied to '(java.lang.String)'">("hey!")</error>;
}
}
@@ -0,0 +1,18 @@
import java.util.List;
public class SubClass extends BaseClass<String> {
public static void main(String[] args) {
new SubClass().method(null);
}
@Override
public void method(List list) {}
}
class BaseClass<E> implements EntityListListener<E> {
public void method(List list) {}
}
interface EntityListListener<E> {
public void method(List<E> list);
}
@@ -0,0 +1,9 @@
abstract class TypeToken<T> {
private <T> TypeToken<T> tt(Class<T> t) { return null; }
private <T> void checkedTestInexactSupertype(TypeToken<T> expectedSuperclass, TypeToken<? extends T> type) {}
TypeToken<? super Integer> ft = null;
{
checkedTestInexactSupertype(ft, tt(Integer.class));
}
}
@@ -0,0 +1,13 @@
import java.io.Serializable;
interface A<T extends Serializable>
{
<S extends T> S foo(S s);
}
class B implements A<Number>
{
@Override
public <S extends Number> S foo(S s)
{
return s;
}
}
@@ -0,0 +1,22 @@
abstract class IdeaBugTest<M extends IdeaBugTest.Mapping>
{
static class Mapping {}
}
class BugTestSub extends IdeaBugTest<<error descr="SubMapping is not accessible in current context">BugTestSub.SubMapping</error>>
{
public abstract static class SubMapping extends Mapping {}
}
class BugTestSub1 extends IdeaBugTest<BugTestSub1.SubMapping>
{
public abstract static class SubMapping extends IdeaBugTest.Mapping {} //fqn here
}
class AbstractSettings {
interface State {}
}
interface SomeInterface<T> {}
class Settings extends AbstractSettings implements SomeInterface<Settings.MyState> {
static class MyState implements State {}
}
@@ -0,0 +1,8 @@
class A<T extends A.B> {
class B extends A<B> {}
}
class C<T> {
class D extends C<T> {}
<T extends C<String>.D> void foo(){}
}
@@ -0,0 +1,17 @@
class A1<T> {}
class B1<T extends A1<? super A1<? super T>>>{
{
T a = null;
<error descr="Incompatible types. Found: 'T', required: 'A1<? super T>'">A1<? super T> b = a;</error>
}
}
class A<T> {}
class B<T extends A<? super A<? super T>>> {
void bar(T x){
foo(x);
}
void foo(A<? super T> x){}
void foo(Object x){}
}
@@ -0,0 +1,5 @@
class A<T> {
class B<S> {
<error descr="Improper formed type; some type parameters are missing">A<T>.B</error> x;
}
}
@@ -0,0 +1,9 @@
abstract class A<S> {
abstract <T> T foo(T x, T y);
{
A<? extends A<? extends Throwable>> a = null;
A<? extends A<?>> b = null;
foo(a, b);
}
}
@@ -0,0 +1,8 @@
abstract class A<S> {
abstract <T extends A<? extends Throwable>> T foo(T y);
{
A<?> a = null;
<error descr="Inferred type 'A<capture<?>>' for type parameter 'T' is not within its bound; should extend 'A<? extends java.lang.Throwable>'">foo(a)</error>;
}
}
@@ -0,0 +1,13 @@
abstract class A {
abstract <S, T extends Iterable<S>> void foo();
{
foo();
}
}
class X{
<T extends Enum<T>> void foo(){
foo();
}
}
@@ -0,0 +1,6 @@
abstract class A<S> {
abstract <T extends S> void foo();
void bar(A<? super Exception> x){
x.<<error descr="Type parameter 'String[]' is not within its bound; should extend 'capture<? super java.lang.Exception>'">String[]</error>>foo();
}
}
@@ -0,0 +1,12 @@
package pck;
abstract class A<S> {
S y;
void bar(A<? extends int[]> x){
Object obj = <error descr="Array type expected; found: 'capture<? extends int[]>'">x.y</error>[0];
}
void baz(A<? super int[]> x){
Object obj = <error descr="Array type expected; found: 'capture<? super int[]>'">x.y</error>[0];
}
}
@@ -0,0 +1,6 @@
class A<T> {
<S extends A<? extends T>> void foo(){}
void bar(A<?> a){
a.<<error descr="Type parameter 'A' is not within its bound; should extend 'A<capture<?>>'">A<?></error>>foo();
}
}
@@ -0,0 +1,8 @@
class C<T> {
void foo(C<C<?>> x) {
C<Object> c = bar(x);
}
<T> C<T> bar(C<? super C<T>> x){
return null;
}
}
@@ -0,0 +1,10 @@
class C<<warning descr="Type parameter 'T' is never used">T</warning>>{}
class A<<warning descr="Type parameter 'S' is never used">S</warning>,<warning descr="Type parameter 'T' is never used">T</warning>> {}
class B<S,T extends C<S>> extends A<S,T> {
void foo(B<?,?> x){
bar(x);
}
<S, T> void bar(A<S,T> x){
System.out.println(x);
}
}
@@ -0,0 +1,13 @@
class A<T> {}
interface IA{
<T> void foo(A<? extends T[]> x);
}
interface IB{
<T> int foo(A<? extends T> x);
}
class C {
<<error descr="'foo(A<? extends T>)' in 'IB' clashes with 'foo(A<? extends T[]>)' in 'IA'; both methods have same erasure, yet neither overrides the other"></error><error descr="'foo(A<? extends T>)' in 'IB' clashes with 'foo(A<? extends T[]>)' in 'IA'; both methods have same erasure, yet neither overrides the other"></error>T extends IA & IB> void bar(T x, A<String[]> y){
<error descr="Incompatible types. Found: 'void', required: 'int'">int z = x.foo(y);</error>
}
}
@@ -0,0 +1,9 @@
class A<S> {
void bar(A<? super Exception> x, A<? super Throwable> y){
foo(x, y);
}
<T> T foo(A<? super T> x, A<? super T> y){
return null;
}
}
@@ -0,0 +1,9 @@
class A<T> {
Exception[] bar(A<? super Exception[]> x, A<? super Throwable[]> y){
return this.foo(x, y);
}
<T> T foo(A<? super T> x, A<? super T> y){
return null;
}
}
@@ -0,0 +1,11 @@
class A<T> {
A<A<? extends T>> foo(){
return null;
}
void bar(A<?> x){
baz<error descr="'baz(A<A<?>>)' in 'A' cannot be applied to '(A<A<capture<?>>>)'">(x.foo())</error>;
}
<S> void baz(A<A<? extends S>> x){}
}
@@ -0,0 +1,11 @@
class A<T> {
A<A<? super A<T>>> foo(){
return null;
}
void bar(A<?> x){
baz(x.foo());
}
<S> void baz(A<A<? super A<S>>> x){}
}
@@ -0,0 +1,4 @@
class A<K>{
void foo(A<A<A<String>>> b){ bar(b); }
<U, S extends A<U>, T extends A<S>> void bar(A<T> a){}
}
@@ -0,0 +1,12 @@
interface IA<T> {
IA<? extends T> foo();
}
class A {
void baz(IA<? extends Throwable> x) {
bar(x.foo());
}
<T extends Throwable> void bar(IA<T> a) {
}
}
@@ -0,0 +1,41 @@
abstract class A<T, S> {
abstract <T> void foo(A<? extends T, ? extends T> x);
void bar(A<? extends Throwable, ? extends Exception> x){
foo(x);
}
}
abstract class A0<T, S> {
abstract <T> void foo(A0<? extends T, ? extends T> x);
void bar(A0<? extends Exception, ? extends Throwable> x){
foo(x);
}
}
abstract class A1<T, S> {
abstract <T> void foo(A1<? extends T, ? extends T> x);
void bar(A1<? extends Throwable, Exception> x){
foo(x);
}
}
abstract class A10<T, S> {
abstract <T> void foo(A10<? extends T, ? extends T> x);
void bar(A10<Throwable, Exception> x){
foo(x);
}
}
abstract class A2<T, S> {
abstract <T> void foo(A2<? super T, ? super T> x);
void bar(A2<? super Exception, ? super Throwable> x){
foo(x);
}
}
abstract class A20<T, S> {
abstract <T> void foo(A20<? super T, ? super T> x);
void bar(A20<? super Throwable, ? super Exception> x){
foo(x);
}
}
@@ -0,0 +1,7 @@
abstract class A {
abstract <T extends Iterable & Cloneable> void foo();
}
abstract class B extends A{
abstract <T extends Cloneable & Iterable> void foo();
}
@@ -0,0 +1,26 @@
class A<T, S> {
}
class B<L> {
A<L, L> foo() {
return null;
}
void bar(B<?> b, A<?, ?> foo1) {
baz(b.foo());
A<?, ?> foo = b.foo();
baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo)</error>;
baz<error descr="'baz(A<K,K>)' in 'B' cannot be applied to '(A<capture<?>,capture<?>>)'">(foo1)</error>;
}
<K> void baz(A<K, K> a) {
}
}
class C<T,S>{}
class D<T> extends C<T,T> {
void foo(D<?> x){ bar(x); }
<T> void bar(C<T,T> x){}
}
@@ -0,0 +1,5 @@
class D<T> {
void foo(D<D<?>> x){ this.bar(x); }
<T extends Throwable> void bar(D<? super D<T>> x){}
}
@@ -0,0 +1,9 @@
interface IA {
<T extends Cloneable & Iterable> void foo(T x);
<T extends Iterable & Cloneable> void foo(T x);
}
abstract class A<T extends Throwable> {
abstract <T extends Comparable<?> & Iterable> void foo(T x, A<?> y);
abstract <T extends Iterable & Comparable<?>> void foo(T x, A<? extends Throwable> y);
}
@@ -0,0 +1,7 @@
abstract class B<T> {
abstract <S extends T> void foo(T x, S y);
}
class A extends B<String> {
void foo(String x, String y) {}
}
@@ -0,0 +1,10 @@
interface IA {
<T> void a(Iterable<String> x);
}
interface IB {
<T> void a(Iterable x);
}
<error descr="'a(Iterable)' in 'IB' clashes with 'a(Iterable<String>)' in 'IA'; both methods have same erasure, yet neither overrides the other">abstract class C implements IA, IB</error> {}
@@ -0,0 +1,18 @@
class A<S> {
<T> T foo(T x, S y){
return x;
}
}
class B<S> extends A<S> {
Object foo(Object x, Object y){
return x;
}
}
<error descr="'foo(T, S)' in 'A' clashes with 'foo(Object, Object)' in 'B'; both methods have same erasure, yet neither overrides the other">class C extends B<String></error> {
@Override
<T> T foo(T x, String y) {
<error descr="Incompatible types. Found: 'java.lang.Object', required: 'T'">return super.foo(x, y);</error>
}
}
@@ -0,0 +1,7 @@
class A<T> {
<T extends A<T>> void foo(T x){}
void bar(A<?> x){
foo<error descr="'foo(T)' in 'A' cannot be applied to '(A<capture<?>>)'">(x)</error>;
}
}
@@ -0,0 +1,43 @@
class A<T> {}
class B<T> extends A<A<T>> {
void bar(B<?> b, B<? extends String> eb, B<? super String> sb, B<String> s) {
foo(b);
foo(eb);
foo(sb);
foo(s);
<error descr="Inferred type 'capture<?>' for type parameter 'T' is not within its bound; should extend 'java.lang.String'">foo1(b)</error>;
foo1(eb);
<error descr="Inferred type 'capture<? super java.lang.String>' for type parameter 'T' is not within its bound; should extend 'java.lang.String'">foo1(sb)</error>;
foo1(s);
foo2(b);
foo2(eb);
foo2(sb);
foo2(s);
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
foo3<error descr="'foo3(A<A<? extends java.lang.String>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
foo3<error descr="'foo3(A<A<?>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
foo3<error descr="'foo3(A<A<? extends java.lang.String>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<?>>)'">(b)</error>;
foo4<error descr="'foo4(A<A<? super T>>)' in 'B' cannot be applied to '(B<capture<? extends java.lang.String>>)'">(eb)</error>;
foo4<error descr="'foo4(A<A<? super java.lang.String>>)' in 'B' cannot be applied to '(B<capture<? super java.lang.String>>)'">(sb)</error>;
foo4<error descr="'foo4(A<A<? super java.lang.String>>)' in 'B' cannot be applied to '(B<java.lang.String>)'">(s)</error>;
foo5(b);
foo5(eb);
foo5(sb);
foo5(s);
}
<T> void foo(A<A<T>> x) {}
<T extends String> void foo1(A<A<T>> x) {}
<T> void foo2(A<? extends A<T>> x) {}
<T> void foo3(A<A<? extends T>> x) {}
<T> void foo4(A<A<? super T>> x) {}
<T> void foo5(A<? super A<T>> x) {}
}
@@ -0,0 +1,7 @@
abstract class A<T>{
abstract void foo(T x);
class B extends A<B> {
@Override
void foo(A<T>.B x) {}
}
}
@@ -0,0 +1,9 @@
class C<T>{
static class D{
class E{
<error descr="'C.this' cannot be referenced from a static context">T</error> x;
}
}
}
class T{}
@@ -0,0 +1,7 @@
abstract class C{
abstract <T> T foo(T x, T y);
{
Long s = (Long) foo(1,1L);
}
}
@@ -0,0 +1,9 @@
abstract class A{
abstract <S extends Number & Comparable<?>, T extends Number & Comparable<? extends S>> T foo(
Comparable<? extends T> x,
Comparable<? extends T> y);
{
foo(1, 1L);
}
}
@@ -0,0 +1,8 @@
class B<T,S>{}
abstract class A<T> {
abstract B<T,T> foo();
<T> void baz(B<T,T> b){}
void bar(A<?> a){
baz(a.foo());
}
}
@@ -0,0 +1,17 @@
abstract class A<T>{
abstract <S> S foo(S x, S y);
<S extends Number & Comparable<? extends Number>> void baz(A<S> a){}
void bar(A<Long> x, A<Integer> y){
baz<error descr="'baz(A<S>)' in 'A' cannot be applied to '(A<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
}
}
abstract class A1<T>{
abstract <S> S foo(S x, S y);
<T extends Number & Comparable<?>, S extends Number & Comparable<? extends T>> void baz(A1<S> a){}
void bar(A1<Long> x, A1<Integer> y){
baz<error descr="'baz(A1<S>)' in 'A1' cannot be applied to '(A1<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
}
}
@@ -0,0 +1,8 @@
abstract class A<T>{
abstract <S> S foo(S x, S y);
<S extends Number & Comparable<?>> void baz(A<S> a){}
void bar(A<Long> x, A<Integer> y){
baz<error descr="'baz(A<S>)' in 'A' cannot be applied to '(A<capture<? extends java.lang.Number & java.lang.Comparable<? extends java.lang.Comparable<?>>>>)'">(foo(x, y))</error>;
}
}
@@ -0,0 +1,16 @@
import java.util.*;
abstract class A {
abstract <T> T baz(List<? super List<? super T>> a);
void bar(List<List<?>> x){
String s = baz(x);
}
}
abstract class A1{
abstract <T> T baz(List<? super T> a);
void bar(List<?> x){
String o = baz<error descr="'baz(java.util.List<? super T>)' in 'A1' cannot be applied to '(java.util.List<capture<?>>)'">(x)</error>;
}
}
@@ -0,0 +1,9 @@
import java.util.*;
interface C<T> extends List<List<T>>{}
abstract class A {
abstract <T> T baz(List<? super List<? super T>> a);
void bar(C<?> x){
baz<error descr="'baz(java.util.List<? super java.util.List<? super T>>)' in 'A' cannot be applied to '(C<capture<?>>)'">(x)</error>;
}
}

Some files were not shown because too many files have changed in this diff Show More