提交 8c2d9559 编写于 作者: J jlahoda

8057794: Compiler Error when obtaining .class property

Summary: Ensuring a non-null type and sym for illegal T.class to prevent downstream errors.
Reviewed-by: mcimadamore
上级 e780e71f
......@@ -3226,8 +3226,9 @@ public class Attr extends JCTree.Visitor {
elt = ((ArrayType)elt.unannotatedType()).elemtype;
if (elt.hasTag(TYPEVAR)) {
log.error(tree.pos(), "type.var.cant.be.deref");
result = types.createErrorType(tree.type);
return;
result = tree.type = types.createErrorType(tree.name, site.tsym, site);
tree.sym = tree.type.tsym;
return ;
}
}
......
/**
* @test /nodynamiccopyright/
* @bug 8057794
* @summary The tree for TypeVar.class does not have a type set, which leads to an NPE when
* checking if deferred attribution is needed
* @compile/fail/ref=T8057794.out -XDrawDiagnostics T8057794.java
*/
class T8057794<T> {
void t() {
System.out.println(T.class.getSimpleName());
}
}
T8057794.java:10:29: compiler.err.type.var.cant.be.deref
1 error
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册