< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeCopier.java

Print this page
rev 51104 : imported patch switch

@@ -138,19 +138,21 @@
     }
 
     @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitBreak(BreakTree node, P p) {
         JCBreak t = (JCBreak) node;
-        return M.at(t.pos).Break(t.label);
+        JCExpression value = copy(t.value, p);
+        return M.at(t.pos).Break(value);
     }
 
     @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitCase(CaseTree node, P p) {
         JCCase t = (JCCase) node;
-        JCExpression pat = copy(t.pat, p);
+        List<JCExpression> pats = copy(t.pats, p);
         List<JCStatement> stats = copy(t.stats, p);
-        return M.at(t.pos).Case(pat, stats);
+        JCTree body = copy(t.body, p);
+        return M.at(t.pos).Case(t.caseKind, pats, stats, body);
     }
 
     @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitCatch(CatchTree node, P p) {
         JCCatch t = (JCCatch) node;

@@ -369,10 +371,19 @@
         List<JCCase> cases = copy(t.cases, p);
         return M.at(t.pos).Switch(selector, cases);
     }
 
     @DefinedBy(Api.COMPILER_TREE)
+    @SuppressWarnings("removal")
+    public JCTree visitSwitchExpression(SwitchExpressionTree node, P p) {
+        JCSwitchExpression t = (JCSwitchExpression) node;
+        JCExpression selector = copy(t.selector, p);
+        List<JCCase> cases = copy(t.cases, p);
+        return M.at(t.pos).SwitchExpression(selector, cases);
+    }
+
+    @DefinedBy(Api.COMPILER_TREE)
     public JCTree visitSynchronized(SynchronizedTree node, P p) {
         JCSynchronized t = (JCSynchronized) node;
         JCExpression lock = copy(t.lock, p);
         JCBlock body = copy(t.body, p);
         return M.at(t.pos).Synchronized(lock, body);

@@ -557,11 +568,11 @@
     public JCTree visitOther(Tree node, P p) {
         JCTree tree = (JCTree) node;
         switch (tree.getTag()) {
             case LETEXPR: {
                 LetExpr t = (LetExpr) node;
-                List<JCVariableDecl> defs = copy(t.defs, p);
+                List<JCStatement> defs = copy(t.defs, p);
                 JCExpression expr = copy(t.expr, p);
                 return M.at(t.pos).LetExpr(defs, expr);
             }
             default:
                 throw new AssertionError("unknown tree tag: " + tree.getTag());
< prev index next >