import java.util.*; import java.util.Comparator; class VarianceTesting { void method(List l) { // l.add(new VarianceTesting()); l.add(null); } static void shuffle(Collection c) {} static class X { T field; T[] arrayField; T[] method() {return arrayField;}; void putAll(Collection c) {} } void method1(List l) { List l1 = new ArrayList(); l1.add(new VarianceTesting()); List> lll = null; lll.add(l1); X x = new X(); VarianceTesting z = x.field; VarianceTesting[] v = x.arrayField; VarianceTesting v1 = x.arrayField[0]; x.arrayField[0] = new VarianceTesting(); x.field = new VarianceTesting(); VarianceTesting[] k = x.method(); k[0] = new VarianceTesting(); x.method()[0] = new VarianceTesting(); x.arrayField = new VarianceTesting[10]; l1.addAll(new ArrayList()); List l2 = new ArrayList(); List l3 = l2; VarianceTesting t = l1.get(0); l.add(new VarianceTesting()); l.add(null); VarianceTesting t1 = l.get(0); X x1 = null; x1.putAll(new ArrayList()); List unknownlist = l; List unknownlist1 = new ArrayList(); List unknownlist2 = new ArrayList<?>(); shuffle(l); shuffle(new ArrayList()); List lllll = new ArrayList(); lllll.removeAll(new ArrayList()); } } class SuperTester { void go(Acceptor acceptor, U u) { acceptor.accept(this, u); } static class Acceptor { void accept(SuperTester tester, V v) { } } } class SCR40202 { void foo(Map map) { for (Iterator> it = map.entrySet().iterator(); it.hasNext();) { } } } class CaptureTest { static class Emum { T t; public static > T valueOf(Class enumType, String name) { return null; } } void foo (Class> clazz) { Emum.valueOf(clazz, "CCC"); } } class SuperTest { public List> waitingList; public Comparator> SIZE_COMPARATOR; { //This call has its type arguments inferred alright: T -> List> Collections.sort(waitingList, SIZE_COMPARATOR); } } class Bug { static class B { } static class D { B f() { return null; } } void h(B b) { } void foo(D d) { h(d.f()); //This call is OK as a result of reopening captured wildcard for calling "h" } } //IDEA-4215 class Case2 { class A {} class B extends A {} Comparator aComparator; Case2() { ArrayList blist = new ArrayList(); // this call is OK: T -> B Collections.sort(blist, aComparator); } } class S1 { void f(List l1, T l2) { } void bar(List k) { f(k, k.get(0)); } } class S2 { void f(List l1, List l2) { } void bar(List k) { f(k, k); } } class S3 { void f(Map l2) { } void bar(Map k) { f(k); } } class TypeBug { private static class ValueHolder { public T value; } public static void main(final String[] args) { List> multiList = new ArrayList>(); ValueHolder intHolder = new ValueHolder(); intHolder.value = 1; ValueHolder doubleHolder = new ValueHolder(); doubleHolder.value = 1.5; multiList.add(intHolder); multiList.add(doubleHolder); swapFirstTwoValues(multiList); //need to be highlighted // this line causes a ClassCastException when checked. Integer value = intHolder.value; System.out.println(value); } private static void swapFirstTwoValues(List> multiList) { ValueHolder intHolder = multiList.get(0); ValueHolder doubleHolder = multiList.get(1); intHolder.value = doubleHolder.value; } } class OtherBug { public static void foo(List foos) { final Comparator comparator = createComparator(); Collections.sort(foos, comparator); //this call is OK } private static Comparator createComparator() { return null; } public interface Foo { } } class OtherBug1 { public static void foo(List foos) { final Comparator comparator = createComparator(); Collections.sort(foos, comparator); } private static Comparator createComparator() { return null; } public interface Foo { } } //IDEADEV-7187 class AA , C extends AA>{} //end of IDEADEV-7187 //IDEADEV-8697 class GenericTest99,F> { } class GenericTest99D> extends GenericTest99 { } class Use99,F> { } class Use99n extends Use99,Double> { } //end of IDEADEV-8697 class IDEA79360 { public static void main(Map map, Map test) { map.putAll(test); map.put("", ""); map.put(new Object(), new Object()); map = new HashMap(test); } } class GenericFailureExample { interface Descriptor> { Class getType(); } void isMarkedFaultyButCompilesClean(Descriptor n) { bar(n.getType()); } > void butThisWorks(Descriptor n) { bar(n.getType()); } > Comparator bar(Class type) { return null; } } //IDEA-67675 abstract class A67675 { abstract T foo(); } abstract class B67675 extends A67675 { } class C67675> { void foo(T x) { x.foo()[0] = ""; } }