提交 e57cefff 编写于 作者: J jlahoda

8021338: Diamond finder may mark a required type argument as unnecessary

Reviewed-by: mcimadamore
上级 208b11e4
...@@ -2195,7 +2195,9 @@ public class Attr extends JCTree.Visitor { ...@@ -2195,7 +2195,9 @@ public class Attr extends JCTree.Visitor {
syms.objectType : syms.objectType :
clazztype; clazztype;
if (!inferred.isErroneous() && if (!inferred.isErroneous() &&
types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings)) { (allowPoly && pt() == Infer.anyPoly ?
types.isSameType(inferred, clazztype) :
types.isAssignable(inferred, pt().hasTag(NONE) ? polyPt : pt(), types.noWarnings))) {
String key = types.isSameType(clazztype, inferred) ? String key = types.isSameType(clazztype, inferred) ?
"diamond.redundant.args" : "diamond.redundant.args" :
"diamond.redundant.args.1"; "diamond.redundant.args.1";
......
/* /*
* @test /nodynamiccopyright/ * @test /nodynamiccopyright/
* @bug 6939780 7020044 8009459 * @bug 6939780 7020044 8009459 8021338
* *
* @summary add a warning to detect diamond sites * @summary add a warning to detect diamond sites
* @author mcimadamore * @author mcimadamore
...@@ -36,4 +36,15 @@ class T6939780 { ...@@ -36,4 +36,15 @@ class T6939780 {
void gw(Foo<?> fw) { } void gw(Foo<?> fw) { }
void gn(Foo<Number> fn) { } void gn(Foo<Number> fn) { }
static class Foo2<X> {
X copy(X t) {
return t;
}
}
void testReciever() {
Number s = new Foo2<Number>().copy(0);
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册