Skip to content

Commit

Permalink
Don't try to resolve the type of the RHS if its a primitive.
Browse files Browse the repository at this point in the history
  • Loading branch information
samskivert committed Dec 28, 2010
1 parent 21e4982 commit 8657960
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/ductilej/detyper/Detype.java
Original file line number Diff line number Diff line change
Expand Up @@ -1184,11 +1184,14 @@ protected boolean inStatic ()

protected boolean isConstDecl (JCVariableDecl tree)
{
// the declared type must be (resolvable and) a primitive or a string
Type vtype = _resolver.resolveType(_env, tree.vartype, Kinds.TYP);
if (vtype != null && tree.vartype.getTag() != JCTree.TYPEIDENT &&
!_types.isSameType(vtype, _syms.stringType)) {
return false;
// if the type of the RHS is not a primitive...
if (tree.vartype.getTag() != JCTree.TYPEIDENT) {
// ...then the only other possible const expression is a string
Type vtype = _resolver.resolveType(_env, tree.vartype, Kinds.TYP);
// if we could not resolve the type of the RHS, it's definitely not a string literal
if (vtype == null || !_types.isSameType(vtype, _syms.stringType)) {
return false;
}
}

// it must be explicitly declared final or be an interface field member (which is
Expand Down

0 comments on commit 8657960

Please sign in to comment.