diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java index c0abee565..07062e52e 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseAST.java @@ -95,7 +95,7 @@ public abstract class BaseAST implements AST { if ( t==null ) { return; // do nothing upon addChild(null) } - BaseAST childTree = (BaseAST)t; + BaseAST childTree = t; if ( childTree.isNil() ) { // t is an empty node possibly with children if ( this.children!=null && this.children == childTree.children ) { throw new RuntimeException("attempt to add child list to itself"); @@ -240,7 +240,7 @@ public abstract class BaseAST implements AST { public void freshenParentAndChildIndexesDeeply(int offset) { int n = getChildCount(); for (int c = offset; c < n; c++) { - BaseAST child = (BaseAST)getChild(c); + BaseAST child = getChild(c); child.setChildIndex(c); child.setParent(this); child.freshenParentAndChildIndexesDeeply(); diff --git a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java index 8d3479ef4..807855be6 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java +++ b/runtime/Java/src/org/antlr/v4/runtime/tree/BaseASTAdaptor.java @@ -57,7 +57,7 @@ public abstract class BaseASTAdaptor implements ASTAdaptor @Override public boolean isNil(T tree) { - return ((AST)tree).isNil(); + return tree.isNil(); } @Override @@ -96,7 +96,7 @@ public abstract class BaseASTAdaptor implements ASTAdaptor @Override public void addChild(T t, T child) { if ( t!=null && child!=null ) { - ((BaseAST)t).addChild((BaseAST) child); + t.addChild(child); } } @@ -231,20 +231,20 @@ public abstract class BaseASTAdaptor implements ASTAdaptor @Override public int getChildCount(T t) { - return ((BaseAST)t).getChildCount(); + return t.getChildCount(); } @Override public int getUniqueID(T node) { if ( treeToUniqueIDMap==null ) { - treeToUniqueIDMap = new HashMap(); + treeToUniqueIDMap = new HashMap(); } - Integer prevID = (Integer)treeToUniqueIDMap.get(node); + Integer prevID = treeToUniqueIDMap.get(node); if ( prevID!=null ) { return prevID; } int ID = uniqueNodeID; - treeToUniqueIDMap.put((BaseAST)node, ID); + treeToUniqueIDMap.put(node, ID); uniqueNodeID++; return ID; // GC makes these nonunique: