提交 02835ba7 编写于 作者: J jjg

6917122: provide utility method to find the inner most type of a type tree

Reviewed-by: darcy, jjg
Contributed-by: mali@csail.mit.edu, mernst@cs.washington.edu
上级 b75daa6d
......@@ -1152,20 +1152,7 @@ public class Pretty extends JCTree.Visitor {
// Prints the inner element type of a nested array
private void printBaseElementType(JCTree tree) throws IOException {
switch (tree.getTag()) {
case JCTree.TYPEARRAY:
printBaseElementType(((JCArrayTypeTree)tree).elemtype);
return;
case JCTree.WILDCARD:
printBaseElementType(((JCWildcard)tree).inner);
return;
case JCTree.ANNOTATED_TYPE:
printBaseElementType(((JCAnnotatedType)tree).underlyingType);
return;
default:
printExpr(tree);
return;
}
printExpr(TreeInfo.innermostType(tree));
}
// prints the brackets of a nested array in reverse order
......
......@@ -891,4 +891,17 @@ public class TreeInfo {
throw new AssertionError("Unexpected type tree: " + tree);
}
}
public static JCTree innermostType(JCTree type) {
switch (type.getTag()) {
case JCTree.TYPEARRAY:
return innermostType(((JCArrayTypeTree)type).elemtype);
case JCTree.WILDCARD:
return innermostType(((JCWildcard)type).inner);
case JCTree.ANNOTATED_TYPE:
return innermostType(((JCAnnotatedType)type).underlyingType);
default:
return type;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册