Sun, 28 Jul 2013 10:17:45 +0200
8021338: Diamond finder may mark a required type argument as unnecessary
Reviewed-by: mcimadamore
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Sun Jul 28 10:17:45 2013 +0200 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Sun Jul 28 10:17:45 2013 +0200 1.3 @@ -2195,7 +2195,9 @@ 1.4 syms.objectType : 1.5 clazztype; 1.6 if (!inferred.isErroneous() && 1.7 - types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings)) { 1.8 + (allowPoly && pt() == Infer.anyPoly ? 1.9 + types.isSameType(inferred, clazztype) : 1.10 + types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings))) { 1.11 String key = types.isSameType(clazztype, inferred) ? 1.12 "diamond.redundant.args" : 1.13 "diamond.redundant.args.1";
2.1 --- a/test/tools/javac/generics/diamond/6939780/T6939780.java Sun Jul 28 10:17:45 2013 +0200 2.2 +++ b/test/tools/javac/generics/diamond/6939780/T6939780.java Sun Jul 28 10:17:45 2013 +0200 2.3 @@ -1,6 +1,6 @@ 2.4 /* 2.5 * @test /nodynamiccopyright/ 2.6 - * @bug 6939780 7020044 8009459 2.7 + * @bug 6939780 7020044 8009459 8021338 2.8 * 2.9 * @summary add a warning to detect diamond sites 2.10 * @author mcimadamore 2.11 @@ -36,4 +36,15 @@ 2.12 2.13 void gw(Foo<?> fw) { } 2.14 void gn(Foo<Number> fn) { } 2.15 + 2.16 + static class Foo2<X> { 2.17 + X copy(X t) { 2.18 + return t; 2.19 + } 2.20 + } 2.21 + 2.22 + void testReciever() { 2.23 + Number s = new Foo2<Number>().copy(0); 2.24 + } 2.25 + 2.26 }