8057794: Compiler Error when obtaining .class property
Ensuring a non-null type and sym for illegal T.class to prevent downstream errors. Reviewed-by: mcimadamore
This commit is contained in:
parent
2700003cdb
commit
c30ea9e1d2
@ -3195,8 +3195,9 @@ public class Attr extends JCTree.Visitor {
|
|||||||
elt = ((ArrayType)elt).elemtype;
|
elt = ((ArrayType)elt).elemtype;
|
||||||
if (elt.hasTag(TYPEVAR)) {
|
if (elt.hasTag(TYPEVAR)) {
|
||||||
log.error(tree.pos(), "type.var.cant.be.deref");
|
log.error(tree.pos(), "type.var.cant.be.deref");
|
||||||
result = types.createErrorType(tree.type);
|
result = tree.type = types.createErrorType(tree.name, site.tsym, site);
|
||||||
return;
|
tree.sym = tree.type.tsym;
|
||||||
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
langtools/test/tools/javac/lambda/T8057794.java
Normal file
12
langtools/test/tools/javac/lambda/T8057794.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* @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());
|
||||||
|
}
|
||||||
|
}
|
2
langtools/test/tools/javac/lambda/T8057794.out
Normal file
2
langtools/test/tools/javac/lambda/T8057794.out
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
T8057794.java:10:29: compiler.err.type.var.cant.be.deref
|
||||||
|
1 error
|
Loading…
x
Reference in New Issue
Block a user