2013-03-06 15:33:17 +00:00
|
|
|
/*
|
|
|
|
* @test /nodynamiccopyright/
|
2015-03-30 17:09:14 +05:30
|
|
|
* @bug 6939780 7020044 8009459 8021338 8064365 8062373
|
2013-03-06 15:33:17 +00:00
|
|
|
*
|
2015-03-30 17:09:14 +05:30
|
|
|
* @summary add a warning to detect diamond sites (including anonymous class instance creation at source >= 9)
|
2013-03-06 15:33:17 +00:00
|
|
|
* @author mcimadamore
|
2014-12-12 18:07:24 +00:00
|
|
|
* @compile/ref=T6939780_7.out -Xlint:-options -source 7 T6939780.java -XDrawDiagnostics -XDfind=diamond
|
2015-03-30 17:09:14 +05:30
|
|
|
* @compile/ref=T6939780_8.out -Xlint:-options -source 8 T6939780.java -XDrawDiagnostics -XDfind=diamond
|
|
|
|
* @compile/ref=T6939780_9.out -Xlint:-options -source 9 T6939780.java -XDrawDiagnostics -XDfind=diamond
|
2013-03-06 15:33:17 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class T6939780 {
|
|
|
|
|
|
|
|
static class Foo<X extends Number> {
|
|
|
|
Foo() {}
|
|
|
|
Foo(X x) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
void testAssign() {
|
|
|
|
Foo<Number> f1 = new Foo<Number>(1);
|
|
|
|
Foo<?> f2 = new Foo<Number>();
|
|
|
|
Foo<?> f3 = new Foo<Integer>();
|
|
|
|
Foo<Number> f4 = new Foo<Number>(1) {};
|
|
|
|
Foo<?> f5 = new Foo<Number>() {};
|
|
|
|
Foo<?> f6 = new Foo<Integer>() {};
|
|
|
|
}
|
|
|
|
|
|
|
|
void testMethod() {
|
|
|
|
gn(new Foo<Number>(1));
|
|
|
|
gw(new Foo<Number>());
|
|
|
|
gw(new Foo<Integer>());
|
|
|
|
gn(new Foo<Number>(1) {});
|
|
|
|
gw(new Foo<Number>() {});
|
|
|
|
gw(new Foo<Integer>() {});
|
|
|
|
}
|
|
|
|
|
|
|
|
void gw(Foo<?> fw) { }
|
|
|
|
void gn(Foo<Number> fn) { }
|
2013-07-28 10:17:45 +02:00
|
|
|
|
|
|
|
static class Foo2<X> {
|
|
|
|
X copy(X t) {
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void testReciever() {
|
|
|
|
Number s = new Foo2<Number>().copy(0);
|
|
|
|
}
|
|
|
|
|
2013-03-06 15:33:17 +00:00
|
|
|
}
|