1 /*
   2  * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.tree;
  27 
  28 import java.io.IOException;
  29 import java.io.StringWriter;
  30 import java.util.*;
  31 
  32 import javax.lang.model.element.Modifier;
  33 import javax.lang.model.type.TypeKind;
  34 import javax.tools.JavaFileObject;
  35 
  36 import com.sun.source.tree.*;
  37 import com.sun.tools.javac.code.*;
  38 import com.sun.tools.javac.code.Directive.RequiresDirective;
  39 import com.sun.tools.javac.code.Scope.*;
  40 import com.sun.tools.javac.code.Symbol.*;
  41 import com.sun.tools.javac.util.*;
  42 import com.sun.tools.javac.util.DefinedBy.Api;
  43 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
  44 import com.sun.tools.javac.util.List;
  45 
  46 import static com.sun.tools.javac.tree.JCTree.Tag.*;
  47 
  48 import javax.tools.JavaFileManager.Location;
  49 
  50 import com.sun.source.tree.ModuleTree.ModuleKind;
  51 import com.sun.tools.javac.code.Directive.ExportsDirective;
  52 import com.sun.tools.javac.code.Directive.OpensDirective;
  53 import com.sun.tools.javac.code.Type.ModuleType;
  54 
  55 /**
  56  * Root class for abstract syntax tree nodes. It provides definitions
  57  * for specific tree nodes as subclasses nested inside.
  58  *
  59  * <p>Each subclass is highly standardized.  It generally contains
  60  * only tree fields for the syntactic subcomponents of the node.  Some
  61  * classes that represent identifier uses or definitions also define a
  62  * Symbol field that denotes the represented identifier.  Classes for
  63  * non-local jumps also carry the jump target as a field.  The root
  64  * class Tree itself defines fields for the tree's type and position.
  65  * No other fields are kept in a tree node; instead parameters are
  66  * passed to methods accessing the node.
  67  *
  68  * <p>Except for the methods defined by com.sun.source, the only
  69  * method defined in subclasses is `visit' which applies a given
  70  * visitor to the tree. The actual tree processing is done by visitor
  71  * classes in other packages. The abstract class Visitor, as well as
  72  * an Factory interface for trees, are defined as inner classes in
  73  * Tree.
  74  *
  75  * <p>To avoid ambiguities with the Tree API in com.sun.source all sub
  76  * classes should, by convention, start with JC (javac).
  77  *
  78  * <p><b>This is NOT part of any supported API.
  79  * If you write code that depends on this, you do so at your own risk.
  80  * This code and its internal interfaces are subject to change or
  81  * deletion without notice.</b>
  82  *
  83  * @see TreeMaker
  84  * @see TreeInfo
  85  * @see TreeTranslator
  86  * @see Pretty
  87  */
  88 public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition {
  89 
  90     /* Tree tag values, identifying kinds of trees */
  91     public enum Tag {
  92         /** For methods that return an invalid tag if a given condition is not met
  93          */
  94         NO_TAG,
  95 
  96         /** Toplevel nodes, of type TopLevel, representing entire source files.
  97         */
  98         TOPLEVEL,
  99 
 100         /** Package level definitions.
 101          */
 102         PACKAGEDEF,
 103 
 104         /** Import clauses, of type Import.
 105          */
 106         IMPORT,
 107 
 108         /** Class definitions, of type ClassDef.
 109          */
 110         CLASSDEF,
 111 
 112         /** Method definitions, of type MethodDef.
 113          */
 114         METHODDEF,
 115 
 116         /** Variable definitions, of type VarDef.
 117          */
 118         VARDEF,
 119 
 120         /** The no-op statement ";", of type Skip
 121          */
 122         SKIP,
 123 
 124         /** Blocks, of type Block.
 125          */
 126         BLOCK,
 127 
 128         /** Do-while loops, of type DoLoop.
 129          */
 130         DOLOOP,
 131 
 132         /** While-loops, of type WhileLoop.
 133          */
 134         WHILELOOP,
 135 
 136         /** Withfields, of type WithField.
 137          */
 138         WITHFIELD,
 139 
 140         /** For-loops, of type ForLoop.
 141          */
 142         FORLOOP,
 143 
 144         /** Foreach-loops, of type ForeachLoop.
 145          */
 146         FOREACHLOOP,
 147 
 148         /** Labelled statements, of type Labelled.
 149          */
 150         LABELLED,
 151 
 152         /** Switch statements, of type Switch.
 153          */
 154         SWITCH,
 155 
 156         /** Case parts in switch statements/expressions, of type Case.
 157          */
 158         CASE,
 159 
 160         /** Switch expression statements, of type Switch.
 161          */
 162         SWITCH_EXPRESSION,
 163 
 164         /** Synchronized statements, of type Synchronized.
 165          */
 166         SYNCHRONIZED,
 167 
 168         /** Try statements, of type Try.
 169          */
 170         TRY,
 171 
 172         /** Catch clauses in try statements, of type Catch.
 173          */
 174         CATCH,
 175 
 176         /** Conditional expressions, of type Conditional.
 177          */
 178         CONDEXPR,
 179 
 180         /** Conditional statements, of type If.
 181          */
 182         IF,
 183 
 184         /** Expression statements, of type Exec.
 185          */
 186         EXEC,
 187 
 188         /** Break statements, of type Break.
 189          */
 190         BREAK,
 191 
 192         /** Yield statements, of type Yield.
 193          */
 194         YIELD,
 195 
 196         /** Continue statements, of type Continue.
 197          */
 198         CONTINUE,
 199 
 200         /** Return statements, of type Return.
 201          */
 202         RETURN,
 203 
 204         /** Throw statements, of type Throw.
 205          */
 206         THROW,
 207 
 208         /** Assert statements, of type Assert.
 209          */
 210         ASSERT,
 211 
 212         /** Method invocation expressions, of type Apply.
 213          */
 214         APPLY,
 215 
 216         /** Class instance creation expressions, of type NewClass.
 217          */
 218         NEWCLASS,
 219 
 220         /** Array creation expressions, of type NewArray.
 221          */
 222         NEWARRAY,
 223 
 224         /** Lambda expression, of type Lambda.
 225          */
 226         LAMBDA,
 227 
 228         /** Parenthesized subexpressions, of type Parens.
 229          */
 230         PARENS,
 231 
 232         /** Assignment expressions, of type Assign.
 233          */
 234         ASSIGN,
 235 
 236         /** Type cast expressions, of type TypeCast.
 237          */
 238         TYPECAST,
 239 
 240         /** Type test expressions, of type TypeTest.
 241          */
 242         TYPETEST,
 243 
 244         /** Patterns.
 245          */
 246         BINDINGPATTERN,
 247         DEFAULTCASELABEL,
 248         GUARDPATTERN,
 249         PARENTHESIZEDPATTERN,
 250 
 251         /** Indexed array expressions, of type Indexed.
 252          */
 253         INDEXED,
 254 
 255         /** Selections, of type Select.
 256          */
 257         SELECT,
 258 
 259         /** Default values, of type DefaultValueTree.
 260          */
 261         DEFAULT_VALUE,
 262 
 263         /** Member references, of type Reference.
 264          */
 265         REFERENCE,
 266 
 267         /** Simple identifiers, of type Ident.
 268          */
 269         IDENT,
 270 
 271         /** Literals, of type Literal.
 272          */
 273         LITERAL,
 274 
 275         /** Basic type identifiers, of type TypeIdent.
 276          */
 277         TYPEIDENT,
 278 
 279         /** Array types, of type TypeArray.
 280          */
 281         TYPEARRAY,
 282 
 283         /** Parameterized types, of type TypeApply.
 284          */
 285         TYPEAPPLY,
 286 
 287         /** Union types, of type TypeUnion.
 288          */
 289         TYPEUNION,
 290 
 291         /** Intersection types, of type TypeIntersection.
 292          */
 293         TYPEINTERSECTION,
 294 
 295         /** Formal type parameters, of type TypeParameter.
 296          */
 297         TYPEPARAMETER,
 298 
 299         /** Type argument.
 300          */
 301         WILDCARD,
 302 
 303         /** Bound kind: extends, super, exact, or unbound
 304          */
 305         TYPEBOUNDKIND,
 306 
 307         /** metadata: Annotation.
 308          */
 309         ANNOTATION,
 310 
 311         /** metadata: Type annotation.
 312          */
 313         TYPE_ANNOTATION,
 314 
 315         /** metadata: Modifiers
 316          */
 317         MODIFIERS,
 318 
 319         /** An annotated type tree.
 320          */
 321         ANNOTATED_TYPE,
 322 
 323         /** Error trees, of type Erroneous.
 324          */
 325         ERRONEOUS,
 326 
 327         /** Unary operators, of type Unary.
 328          */
 329         POS,                             // +
 330         NEG,                             // -
 331         NOT,                             // !
 332         COMPL,                           // ~
 333         PREINC,                          // ++ _
 334         PREDEC,                          // -- _
 335         POSTINC,                         // _ ++
 336         POSTDEC,                         // _ --
 337 
 338         /** unary operator for null reference checks, only used internally.
 339          */
 340         NULLCHK,
 341 
 342         /** Binary operators, of type Binary.
 343          */
 344         OR,                              // ||
 345         AND,                             // &&
 346         BITOR,                           // |
 347         BITXOR,                          // ^
 348         BITAND,                          // &
 349         EQ,                              // ==
 350         NE,                              // !=
 351         LT,                              // <
 352         GT,                              // >
 353         LE,                              // <=
 354         GE,                              // >=
 355         SL,                              // <<
 356         SR,                              // >>
 357         USR,                             // >>>
 358         PLUS,                            // +
 359         MINUS,                           // -
 360         MUL,                             // *
 361         DIV,                             // /
 362         MOD,                             // %
 363 
 364         /** Assignment operators, of type Assignop.
 365          */
 366         BITOR_ASG(BITOR),                // |=
 367         BITXOR_ASG(BITXOR),              // ^=
 368         BITAND_ASG(BITAND),              // &=
 369 
 370         SL_ASG(SL),                      // <<=
 371         SR_ASG(SR),                      // >>=
 372         USR_ASG(USR),                    // >>>=
 373         PLUS_ASG(PLUS),                  // +=
 374         MINUS_ASG(MINUS),                // -=
 375         MUL_ASG(MUL),                    // *=
 376         DIV_ASG(DIV),                    // /=
 377         MOD_ASG(MOD),                    // %=
 378 
 379         MODULEDEF,
 380         EXPORTS,
 381         OPENS,
 382         PROVIDES,
 383         REQUIRES,
 384         USES,
 385 
 386         /** A synthetic let expression, of type LetExpr.
 387          */
 388         LETEXPR;                         // ala scheme
 389 
 390         private final Tag noAssignTag;
 391 
 392         private static final int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1;
 393 
 394         private Tag(Tag noAssignTag) {
 395             this.noAssignTag = noAssignTag;
 396         }
 397 
 398         private Tag() {
 399             this(null);
 400         }
 401 
 402         public static int getNumberOfOperators() {
 403             return numberOfOperators;
 404         }
 405 
 406         public Tag noAssignOp() {
 407             if (noAssignTag != null)
 408                 return noAssignTag;
 409             throw new AssertionError("noAssignOp() method is not available for non assignment tags");
 410         }
 411 
 412         public boolean isPostUnaryOp() {
 413             return (this == POSTINC || this == POSTDEC);
 414         }
 415 
 416         public boolean isIncOrDecUnaryOp() {
 417             return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC);
 418         }
 419 
 420         public boolean isAssignop() {
 421             return noAssignTag != null;
 422         }
 423 
 424         public int operatorIndex() {
 425             return (this.ordinal() - POS.ordinal());
 426         }
 427     }
 428 
 429     /* The (encoded) position in the source file. @see util.Position.
 430      */
 431     public int pos;
 432 
 433     /* The type of this node.
 434      */
 435     public Type type;
 436 
 437     /* The tag of this node -- one of the constants declared above.
 438      */
 439     public abstract Tag getTag();
 440 
 441     /* Returns true if the tag of this node is equals to tag.
 442      */
 443     public boolean hasTag(Tag tag) {
 444         return tag == getTag();
 445     }
 446 
 447     /** Convert a tree to a pretty-printed string. */
 448     @Override
 449     public String toString() {
 450         StringWriter s = new StringWriter();
 451         try {
 452             new Pretty(s, false).printExpr(this);
 453         }
 454         catch (IOException e) {
 455             // should never happen, because StringWriter is defined
 456             // never to throw any IOExceptions
 457             throw new AssertionError(e);
 458         }
 459         return s.toString();
 460     }
 461 
 462     /** Set position field and return this tree.
 463      */
 464     public JCTree setPos(int pos) {
 465         this.pos = pos;
 466         return this;
 467     }
 468 
 469     /** Set type field and return this tree.
 470      */
 471     public JCTree setType(Type type) {
 472         this.type = type;
 473         return this;
 474     }
 475 
 476     /** Visit this tree with a given visitor.
 477      */
 478     public abstract void accept(Visitor v);
 479 
 480     @DefinedBy(Api.COMPILER_TREE)
 481     public abstract <R,D> R accept(TreeVisitor<R,D> v, D d);
 482 
 483     /** Return a shallow copy of this tree.
 484      */
 485     @Override
 486     public Object clone() {
 487         try {
 488             return super.clone();
 489         } catch(CloneNotSupportedException e) {
 490             throw new RuntimeException(e);
 491         }
 492     }
 493 
 494     /** Get a default position for this tree node.
 495      */
 496     public DiagnosticPosition pos() {
 497         return this;
 498     }
 499 
 500     // for default DiagnosticPosition
 501     public JCTree getTree() {
 502         return this;
 503     }
 504 
 505     // for default DiagnosticPosition
 506     public int getStartPosition() {
 507         return TreeInfo.getStartPos(this);
 508     }
 509 
 510     // for default DiagnosticPosition
 511     public int getPreferredPosition() {
 512         return pos;
 513     }
 514 
 515     // for default DiagnosticPosition
 516     public int getEndPosition(EndPosTable endPosTable) {
 517         return TreeInfo.getEndPos(this, endPosTable);
 518     }
 519 
 520     /**
 521      * Everything in one source file is kept in a {@linkplain JCCompilationUnit} structure.
 522      */
 523     public static class JCCompilationUnit extends JCTree implements CompilationUnitTree {
 524         /** All definitions in this file (ClassDef, Import, and Skip) */
 525         public List<JCTree> defs;
 526         /** The source file name. */
 527         public JavaFileObject sourcefile;
 528         /** The module to which this compilation unit belongs. */
 529         public ModuleSymbol modle;
 530         /** The location in which this compilation unit was found. */
 531         public Location locn;
 532         /** The package to which this compilation unit belongs. */
 533         public PackageSymbol packge;
 534         /** A scope containing top level classes. */
 535         public WriteableScope toplevelScope;
 536         /** A scope for all named imports. */
 537         public NamedImportScope namedImportScope;
 538         /** A scope for all import-on-demands. */
 539         public StarImportScope starImportScope;
 540         /** Line starting positions, defined only if option -g is set. */
 541         public Position.LineMap lineMap = null;
 542         /** A table that stores all documentation comments indexed by the tree
 543          * nodes they refer to. defined only if option -s is set. */
 544         public DocCommentTable docComments = null;
 545         /* An object encapsulating ending positions of source ranges indexed by
 546          * the tree nodes they belong to. Defined only if option -Xjcov is set. */
 547         public EndPosTable endPositions = null;
 548         protected JCCompilationUnit(List<JCTree> defs) {
 549             this.defs = defs;
 550         }
 551         @Override
 552         public void accept(Visitor v) { v.visitTopLevel(this); }
 553 
 554         @DefinedBy(Api.COMPILER_TREE)
 555         public Kind getKind() { return Kind.COMPILATION_UNIT; }
 556 
 557         public JCModuleDecl getModuleDecl() {
 558             for (JCTree tree : defs) {
 559                 if (tree.hasTag(MODULEDEF)) {
 560                     return (JCModuleDecl) tree;
 561                 }
 562             }
 563 
 564             return null;
 565         }
 566 
 567         @DefinedBy(Api.COMPILER_TREE)
 568         public JCModuleDecl getModule() {
 569             return getModuleDecl();
 570         }
 571 
 572         @DefinedBy(Api.COMPILER_TREE)
 573         public JCPackageDecl getPackage() {
 574             // PackageDecl must be the first entry if it exists
 575             if (!defs.isEmpty() && defs.head.hasTag(PACKAGEDEF))
 576                 return (JCPackageDecl)defs.head;
 577             return null;
 578         }
 579         @DefinedBy(Api.COMPILER_TREE)
 580         public List<JCAnnotation> getPackageAnnotations() {
 581             JCPackageDecl pd = getPackage();
 582             return pd != null ? pd.getAnnotations() : List.nil();
 583         }
 584         @DefinedBy(Api.COMPILER_TREE)
 585         public ExpressionTree getPackageName() {
 586             JCPackageDecl pd = getPackage();
 587             return pd != null ? pd.getPackageName() : null;
 588         }
 589 
 590         @DefinedBy(Api.COMPILER_TREE)
 591         public List<JCImport> getImports() {
 592             ListBuffer<JCImport> imports = new ListBuffer<>();
 593             for (JCTree tree : defs) {
 594                 if (tree.hasTag(IMPORT))
 595                     imports.append((JCImport)tree);
 596                 else if (!tree.hasTag(PACKAGEDEF) && !tree.hasTag(SKIP))
 597                     break;
 598             }
 599             return imports.toList();
 600         }
 601         @DefinedBy(Api.COMPILER_TREE)
 602         public JavaFileObject getSourceFile() {
 603             return sourcefile;
 604         }
 605         @DefinedBy(Api.COMPILER_TREE)
 606         public Position.LineMap getLineMap() {
 607             return lineMap;
 608         }
 609         @DefinedBy(Api.COMPILER_TREE)
 610         public List<JCTree> getTypeDecls() {
 611             List<JCTree> typeDefs;
 612             for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) {
 613                 if (!typeDefs.head.hasTag(MODULEDEF)
 614                         && !typeDefs.head.hasTag(PACKAGEDEF) && !typeDefs.head.hasTag(IMPORT)) {
 615                     break;
 616                 }
 617             }
 618             return typeDefs;
 619         }
 620         @Override @DefinedBy(Api.COMPILER_TREE)
 621         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 622             return v.visitCompilationUnit(this, d);
 623         }
 624 
 625         @Override
 626         public Tag getTag() {
 627             return TOPLEVEL;
 628         }
 629     }
 630 
 631     /**
 632      * Package definition.
 633      */
 634     public static class JCPackageDecl extends JCTree implements PackageTree {
 635         public List<JCAnnotation> annotations;
 636         /** The tree representing the package clause. */
 637         public JCExpression pid;
 638         public PackageSymbol packge;
 639         public JCPackageDecl(List<JCAnnotation> annotations, JCExpression pid) {
 640             this.annotations = annotations;
 641             this.pid = pid;
 642         }
 643         @Override
 644         public void accept(Visitor v) { v.visitPackageDef(this); }
 645         @DefinedBy(Api.COMPILER_TREE)
 646         public Kind getKind() {
 647             return Kind.PACKAGE;
 648         }
 649         @DefinedBy(Api.COMPILER_TREE)
 650         public List<JCAnnotation> getAnnotations() {
 651             return annotations;
 652         }
 653         @DefinedBy(Api.COMPILER_TREE)
 654         public JCExpression getPackageName() {
 655             return pid;
 656         }
 657         @Override @DefinedBy(Api.COMPILER_TREE)
 658         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 659             return v.visitPackage(this, d);
 660         }
 661         @Override
 662         public Tag getTag() {
 663             return PACKAGEDEF;
 664         }
 665     }
 666 
 667     /**
 668      * An import clause.
 669      */
 670     public static class JCImport extends JCTree implements ImportTree {
 671         public boolean staticImport;
 672         /** The imported class(es). */
 673         public JCTree qualid;
 674         public com.sun.tools.javac.code.Scope importScope;
 675         protected JCImport(JCTree qualid, boolean importStatic) {
 676             this.qualid = qualid;
 677             this.staticImport = importStatic;
 678         }
 679         @Override
 680         public void accept(Visitor v) { v.visitImport(this); }
 681 
 682         @DefinedBy(Api.COMPILER_TREE)
 683         public boolean isStatic() { return staticImport; }
 684         @DefinedBy(Api.COMPILER_TREE)
 685         public JCTree getQualifiedIdentifier() { return qualid; }
 686 
 687         @DefinedBy(Api.COMPILER_TREE)
 688         public Kind getKind() { return Kind.IMPORT; }
 689         @Override @DefinedBy(Api.COMPILER_TREE)
 690         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 691             return v.visitImport(this, d);
 692         }
 693 
 694         @Override
 695         public Tag getTag() {
 696             return IMPORT;
 697         }
 698     }
 699 
 700     public static abstract class JCStatement extends JCTree implements StatementTree {
 701         @Override
 702         public JCStatement setType(Type type) {
 703             super.setType(type);
 704             return this;
 705         }
 706         @Override
 707         public JCStatement setPos(int pos) {
 708             super.setPos(pos);
 709             return this;
 710         }
 711     }
 712 
 713     public static abstract class JCCaseLabel extends JCTree implements CaseLabelTree {
 714         public abstract boolean isExpression();
 715         public boolean isNullPattern() {
 716             return isExpression() && TreeInfo.isNull((JCExpression) this);
 717         }
 718         public abstract boolean isPattern();
 719     }
 720 
 721     public static abstract class JCExpression extends JCCaseLabel implements ExpressionTree {
 722         @Override
 723         public JCExpression setType(Type type) {
 724             super.setType(type);
 725             return this;
 726         }
 727         @Override
 728         public JCExpression setPos(int pos) {
 729             super.setPos(pos);
 730             return this;
 731         }
 732         public boolean isPoly() { return false; }
 733         public boolean isStandalone() { return true; }
 734 
 735         @Override
 736         public boolean isExpression() {
 737             return true;
 738         }
 739 
 740         @Override
 741         public boolean isPattern() {
 742             return false;
 743         }
 744     }
 745 
 746     /**
 747      * Common supertype for all poly expression trees (lambda, method references,
 748      * conditionals, method and constructor calls)
 749      */
 750     public static abstract class JCPolyExpression extends JCExpression {
 751 
 752         /**
 753          * A poly expression can only be truly 'poly' in certain contexts
 754          */
 755         public enum PolyKind {
 756             /** poly expression to be treated as a standalone expression */
 757             STANDALONE,
 758             /** true poly expression */
 759             POLY
 760         }
 761 
 762         /** is this poly expression a 'true' poly expression? */
 763         public PolyKind polyKind;
 764 
 765         @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
 766         @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
 767     }
 768 
 769     /**
 770      * Common supertype for all functional expression trees (lambda and method references)
 771      */
 772     public static abstract class JCFunctionalExpression extends JCPolyExpression {
 773 
 774         public JCFunctionalExpression() {
 775             //a functional expression is always a 'true' poly
 776             polyKind = PolyKind.POLY;
 777         }
 778 
 779         /** list of target types inferred for this functional expression. */
 780         public Type target;
 781 
 782         public Type getDescriptorType(Types types) {
 783             return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
 784         }
 785     }
 786 
 787     /**
 788      * A class definition.
 789      */
 790     public static class JCClassDecl extends JCStatement implements ClassTree {
 791         /** the modifiers */
 792         public JCModifiers mods;
 793         /** the name of the class */
 794         public Name name;
 795         /** formal class parameters */
 796         public List<JCTypeParameter> typarams;
 797         /** the classes this class extends */
 798         public JCExpression extending;
 799         /** the interfaces implemented by this class */
 800         public List<JCExpression> implementing;
 801         /** the subclasses allowed to extend this class, if sealed */
 802         public List<JCExpression> permitting;
 803         /** all variables and methods defined in this class */
 804         public List<JCTree> defs;
 805         /** the symbol */
 806         public ClassSymbol sym;
 807         protected JCClassDecl(JCModifiers mods,
 808                            Name name,
 809                            List<JCTypeParameter> typarams,
 810                            JCExpression extending,
 811                            List<JCExpression> implementing,
 812                            List<JCExpression> permitting,
 813                            List<JCTree> defs,
 814                            ClassSymbol sym)
 815         {
 816             this.mods = mods;
 817             this.name = name;
 818             this.typarams = typarams;
 819             this.extending = extending;
 820             this.implementing = implementing;
 821             this.permitting = permitting;
 822             this.defs = defs;
 823             this.sym = sym;
 824         }
 825         @Override
 826         public void accept(Visitor v) { v.visitClassDef(this); }
 827 
 828         @DefinedBy(Api.COMPILER_TREE)
 829         public Kind getKind() {
 830             if ((mods.flags & Flags.ANNOTATION) != 0)
 831                 return Kind.ANNOTATION_TYPE;
 832             else if ((mods.flags & Flags.INTERFACE) != 0)
 833                 return Kind.INTERFACE;
 834             else if ((mods.flags & Flags.ENUM) != 0)
 835                 return Kind.ENUM;
 836             else if ((mods.flags & Flags.RECORD) != 0)
 837                 return Kind.RECORD;
 838             else
 839                 return Kind.CLASS;
 840         }
 841 
 842         @DefinedBy(Api.COMPILER_TREE)
 843         public JCModifiers getModifiers() { return mods; }
 844         @DefinedBy(Api.COMPILER_TREE)
 845         public Name getSimpleName() { return name; }
 846         @DefinedBy(Api.COMPILER_TREE)
 847         public List<JCTypeParameter> getTypeParameters() {
 848             return typarams;
 849         }
 850         @DefinedBy(Api.COMPILER_TREE)
 851         public JCExpression getExtendsClause() { return extending; }
 852         @DefinedBy(Api.COMPILER_TREE)
 853         public List<JCExpression> getImplementsClause() {
 854             return implementing;
 855         }
 856         @SuppressWarnings("removal")
 857         @DefinedBy(Api.COMPILER_TREE)
 858         public List<JCExpression> getPermitsClause() {
 859             return permitting;
 860         }
 861         @DefinedBy(Api.COMPILER_TREE)
 862         public List<JCTree> getMembers() {
 863             return defs;
 864         }
 865         @Override @DefinedBy(Api.COMPILER_TREE)
 866         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 867             return v.visitClass(this, d);
 868         }
 869 
 870         @Override
 871         public Tag getTag() {
 872             return CLASSDEF;
 873         }
 874     }
 875 
 876     /**
 877      * A method definition.
 878      */
 879     public static class JCMethodDecl extends JCTree implements MethodTree {
 880         /** method modifiers */
 881         public JCModifiers mods;
 882         /** method name */
 883         public Name name;
 884         /** type of method return value */
 885         public JCExpression restype;
 886         /** type parameters */
 887         public List<JCTypeParameter> typarams;
 888         /** receiver parameter */
 889         public JCVariableDecl recvparam;
 890         /** value parameters */
 891         public List<JCVariableDecl> params;
 892         /** exceptions thrown by this method */
 893         public List<JCExpression> thrown;
 894         /** statements in the method */
 895         public JCBlock body;
 896         /** default value, for annotation types */
 897         public JCExpression defaultValue;
 898         /** method symbol */
 899         public MethodSymbol sym;
 900         /** nascent value that evolves into the return value for a value factory */
 901         public VarSymbol factoryProduct;
 902 
 903         /** does this method completes normally */
 904         public boolean completesNormally;
 905 
 906         protected JCMethodDecl(JCModifiers mods,
 907                             Name name,
 908                             JCExpression restype,
 909                             List<JCTypeParameter> typarams,
 910                             JCVariableDecl recvparam,
 911                             List<JCVariableDecl> params,
 912                             List<JCExpression> thrown,
 913                             JCBlock body,
 914                             JCExpression defaultValue,
 915                             MethodSymbol sym)
 916         {
 917             this.mods = mods;
 918             this.name = name;
 919             this.restype = restype;
 920             this.typarams = typarams;
 921             this.params = params;
 922             this.recvparam = recvparam;
 923             // TODO: do something special if the given type is null?
 924             // receiver != null ? receiver : List.<JCTypeAnnotation>nil());
 925             this.thrown = thrown;
 926             this.body = body;
 927             this.defaultValue = defaultValue;
 928             this.sym = sym;
 929         }
 930         @Override
 931         public void accept(Visitor v) { v.visitMethodDef(this); }
 932 
 933         @DefinedBy(Api.COMPILER_TREE)
 934         public Kind getKind() { return Kind.METHOD; }
 935         @DefinedBy(Api.COMPILER_TREE)
 936         public JCModifiers getModifiers() { return mods; }
 937         @DefinedBy(Api.COMPILER_TREE)
 938         public Name getName() { return name; }
 939         @DefinedBy(Api.COMPILER_TREE)
 940         public JCTree getReturnType() { return restype; }
 941         @DefinedBy(Api.COMPILER_TREE)
 942         public List<JCTypeParameter> getTypeParameters() {
 943             return typarams;
 944         }
 945         @DefinedBy(Api.COMPILER_TREE)
 946         public List<JCVariableDecl> getParameters() {
 947             return params;
 948         }
 949         @DefinedBy(Api.COMPILER_TREE)
 950         public JCVariableDecl getReceiverParameter() { return recvparam; }
 951         @DefinedBy(Api.COMPILER_TREE)
 952         public List<JCExpression> getThrows() {
 953             return thrown;
 954         }
 955         @DefinedBy(Api.COMPILER_TREE)
 956         public JCBlock getBody() { return body; }
 957         @DefinedBy(Api.COMPILER_TREE)
 958         public JCTree getDefaultValue() { // for annotation types
 959             return defaultValue;
 960         }
 961         @Override @DefinedBy(Api.COMPILER_TREE)
 962         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
 963             return v.visitMethod(this, d);
 964         }
 965 
 966         @Override
 967         public Tag getTag() {
 968             return METHODDEF;
 969         }
 970   }
 971 
 972     /**
 973      * A variable definition.
 974      */
 975     public static class JCVariableDecl extends JCStatement implements VariableTree {
 976         /** variable modifiers */
 977         public JCModifiers mods;
 978         /** variable name */
 979         public Name name;
 980         /** variable name expression */
 981         public JCExpression nameexpr;
 982         /** type of the variable */
 983         public JCExpression vartype;
 984         /** variable's initial value */
 985         public JCExpression init;
 986         /** symbol */
 987         public VarSymbol sym;
 988         /** explicit start pos */
 989         public int startPos = Position.NOPOS;
 990         /** declared using `var` */
 991         private boolean declaredUsingVar;
 992 
 993         protected JCVariableDecl(JCModifiers mods,
 994                          Name name,
 995                          JCExpression vartype,
 996                          JCExpression init,
 997                          VarSymbol sym) {
 998             this(mods, name, vartype, init, sym, false);
 999         }
1000 
1001         protected JCVariableDecl(JCModifiers mods,
1002                                  Name name,
1003                                  JCExpression vartype,
1004                                  JCExpression init,
1005                                  VarSymbol sym,
1006                                  boolean declaredUsingVar) {
1007             this.mods = mods;
1008             this.name = name;
1009             this.vartype = vartype;
1010             this.init = init;
1011             this.sym = sym;
1012             this.declaredUsingVar = declaredUsingVar;
1013         }
1014 
1015         protected JCVariableDecl(JCModifiers mods,
1016                          JCExpression nameexpr,
1017                          JCExpression vartype) {
1018             this(mods, null, vartype, null, null, false);
1019             this.nameexpr = nameexpr;
1020             if (nameexpr.hasTag(Tag.IDENT)) {
1021                 this.name = ((JCIdent)nameexpr).name;
1022             } else {
1023                 // Only other option is qualified name x.y.this;
1024                 this.name = ((JCFieldAccess)nameexpr).name;
1025             }
1026         }
1027 
1028         public boolean isImplicitlyTyped() {
1029             return vartype == null;
1030         }
1031 
1032         public boolean declaredUsingVar() {
1033             return declaredUsingVar;
1034         }
1035 
1036         @Override
1037         public void accept(Visitor v) { v.visitVarDef(this); }
1038 
1039         @DefinedBy(Api.COMPILER_TREE)
1040         public Kind getKind() { return Kind.VARIABLE; }
1041         @DefinedBy(Api.COMPILER_TREE)
1042         public JCModifiers getModifiers() { return mods; }
1043         @DefinedBy(Api.COMPILER_TREE)
1044         public Name getName() { return name; }
1045         @DefinedBy(Api.COMPILER_TREE)
1046         public JCExpression getNameExpression() { return nameexpr; }
1047         @DefinedBy(Api.COMPILER_TREE)
1048         public JCTree getType() { return vartype; }
1049         @DefinedBy(Api.COMPILER_TREE)
1050         public JCExpression getInitializer() {
1051             return init;
1052         }
1053         @Override @DefinedBy(Api.COMPILER_TREE)
1054         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1055             return v.visitVariable(this, d);
1056         }
1057 
1058         @Override
1059         public Tag getTag() {
1060             return VARDEF;
1061         }
1062     }
1063 
1064     /**
1065      * A no-op statement ";".
1066      */
1067     public static class JCSkip extends JCStatement implements EmptyStatementTree {
1068         protected JCSkip() {
1069         }
1070         @Override
1071         public void accept(Visitor v) { v.visitSkip(this); }
1072 
1073         @DefinedBy(Api.COMPILER_TREE)
1074         public Kind getKind() { return Kind.EMPTY_STATEMENT; }
1075         @Override @DefinedBy(Api.COMPILER_TREE)
1076         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1077             return v.visitEmptyStatement(this, d);
1078         }
1079 
1080         @Override
1081         public Tag getTag() {
1082             return SKIP;
1083         }
1084     }
1085 
1086     /**
1087      * A statement block.
1088      */
1089     public static class JCBlock extends JCStatement implements BlockTree {
1090         /** flags */
1091         public long flags;
1092         /** statements */
1093         public List<JCStatement> stats;
1094         /** Position of closing brace, optional. */
1095         public int endpos = Position.NOPOS;
1096         protected JCBlock(long flags, List<JCStatement> stats) {
1097             this.stats = stats;
1098             this.flags = flags;
1099         }
1100         @Override
1101         public void accept(Visitor v) { v.visitBlock(this); }
1102 
1103         @DefinedBy(Api.COMPILER_TREE)
1104         public Kind getKind() { return Kind.BLOCK; }
1105         @DefinedBy(Api.COMPILER_TREE)
1106         public List<JCStatement> getStatements() {
1107             return stats;
1108         }
1109         @DefinedBy(Api.COMPILER_TREE)
1110         public boolean isStatic() { return (flags & Flags.STATIC) != 0; }
1111         @Override @DefinedBy(Api.COMPILER_TREE)
1112         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1113             return v.visitBlock(this, d);
1114         }
1115 
1116         @Override
1117         public Tag getTag() {
1118             return BLOCK;
1119         }
1120     }
1121 
1122     /**
1123      * A do loop
1124      */
1125     public static class JCDoWhileLoop extends JCStatement implements DoWhileLoopTree {
1126         public JCStatement body;
1127         public JCExpression cond;
1128         protected JCDoWhileLoop(JCStatement body, JCExpression cond) {
1129             this.body = body;
1130             this.cond = cond;
1131         }
1132         @Override
1133         public void accept(Visitor v) { v.visitDoLoop(this); }
1134 
1135         @DefinedBy(Api.COMPILER_TREE)
1136         public Kind getKind() { return Kind.DO_WHILE_LOOP; }
1137         @DefinedBy(Api.COMPILER_TREE)
1138         public JCExpression getCondition() { return cond; }
1139         @DefinedBy(Api.COMPILER_TREE)
1140         public JCStatement getStatement() { return body; }
1141         @Override @DefinedBy(Api.COMPILER_TREE)
1142         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1143             return v.visitDoWhileLoop(this, d);
1144         }
1145 
1146         @Override
1147         public Tag getTag() {
1148             return DOLOOP;
1149         }
1150     }
1151 
1152     /**
1153      * A while loop
1154      */
1155     public static class JCWhileLoop extends JCStatement implements WhileLoopTree {
1156         public JCExpression cond;
1157         public JCStatement body;
1158         protected JCWhileLoop(JCExpression cond, JCStatement body) {
1159             this.cond = cond;
1160             this.body = body;
1161         }
1162         @Override
1163         public void accept(Visitor v) { v.visitWhileLoop(this); }
1164 
1165         @DefinedBy(Api.COMPILER_TREE)
1166         public Kind getKind() { return Kind.WHILE_LOOP; }
1167         @DefinedBy(Api.COMPILER_TREE)
1168         public JCExpression getCondition() { return cond; }
1169         @DefinedBy(Api.COMPILER_TREE)
1170         public JCStatement getStatement() { return body; }
1171         @Override @DefinedBy(Api.COMPILER_TREE)
1172         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1173             return v.visitWhileLoop(this, d);
1174         }
1175 
1176         @Override
1177         public Tag getTag() {
1178             return WHILELOOP;
1179         }
1180     }
1181 
1182     /**
1183      * A withfield expression
1184      */
1185     public static class JCWithField extends JCExpression implements WithFieldTree {
1186         public JCExpression field;
1187         public JCExpression value;
1188         protected JCWithField(JCExpression field, JCExpression value) {
1189             this.field = field;
1190             this.value = value;
1191         }
1192         @Override
1193         public void accept(Visitor v) { v.visitWithField(this); }
1194 
1195         @DefinedBy(Api.COMPILER_TREE)
1196         public Kind getKind() { return Kind.WITH_FIELD; }
1197         @DefinedBy(Api.COMPILER_TREE)
1198         public JCExpression getField() { return field; }
1199         @DefinedBy(Api.COMPILER_TREE)
1200         public JCExpression getValue() { return value; }
1201         @Override @DefinedBy(Api.COMPILER_TREE)
1202         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1203             return v.visitWithField(this, d);
1204         }
1205 
1206         @Override
1207         public Tag getTag() {
1208             return WITHFIELD;
1209         }
1210     }
1211 
1212     /**
1213      * A for loop.
1214      */
1215     public static class JCForLoop extends JCStatement implements ForLoopTree {
1216         public List<JCStatement> init;
1217         public JCExpression cond;
1218         public List<JCExpressionStatement> step;
1219         public JCStatement body;
1220         protected JCForLoop(List<JCStatement> init,
1221                           JCExpression cond,
1222                           List<JCExpressionStatement> update,
1223                           JCStatement body)
1224         {
1225             this.init = init;
1226             this.cond = cond;
1227             this.step = update;
1228             this.body = body;
1229         }
1230         @Override
1231         public void accept(Visitor v) { v.visitForLoop(this); }
1232 
1233         @DefinedBy(Api.COMPILER_TREE)
1234         public Kind getKind() { return Kind.FOR_LOOP; }
1235         @DefinedBy(Api.COMPILER_TREE)
1236         public JCExpression getCondition() { return cond; }
1237         @DefinedBy(Api.COMPILER_TREE)
1238         public JCStatement getStatement() { return body; }
1239         @DefinedBy(Api.COMPILER_TREE)
1240         public List<JCStatement> getInitializer() {
1241             return init;
1242         }
1243         @DefinedBy(Api.COMPILER_TREE)
1244         public List<JCExpressionStatement> getUpdate() {
1245             return step;
1246         }
1247         @Override @DefinedBy(Api.COMPILER_TREE)
1248         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1249             return v.visitForLoop(this, d);
1250         }
1251 
1252         @Override
1253         public Tag getTag() {
1254             return FORLOOP;
1255         }
1256     }
1257 
1258     /**
1259      * The enhanced for loop.
1260      */
1261     public static class JCEnhancedForLoop extends JCStatement implements EnhancedForLoopTree {
1262         public JCVariableDecl var;
1263         public JCExpression expr;
1264         public JCStatement body;
1265         protected JCEnhancedForLoop(JCVariableDecl var, JCExpression expr, JCStatement body) {
1266             this.var = var;
1267             this.expr = expr;
1268             this.body = body;
1269         }
1270         @Override
1271         public void accept(Visitor v) { v.visitForeachLoop(this); }
1272 
1273         @DefinedBy(Api.COMPILER_TREE)
1274         public Kind getKind() { return Kind.ENHANCED_FOR_LOOP; }
1275         @DefinedBy(Api.COMPILER_TREE)
1276         public JCVariableDecl getVariable() { return var; }
1277         @DefinedBy(Api.COMPILER_TREE)
1278         public JCExpression getExpression() { return expr; }
1279         @DefinedBy(Api.COMPILER_TREE)
1280         public JCStatement getStatement() { return body; }
1281         @Override @DefinedBy(Api.COMPILER_TREE)
1282         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1283             return v.visitEnhancedForLoop(this, d);
1284         }
1285         @Override
1286         public Tag getTag() {
1287             return FOREACHLOOP;
1288         }
1289     }
1290 
1291     /**
1292      * A labelled expression or statement.
1293      */
1294     public static class JCLabeledStatement extends JCStatement implements LabeledStatementTree {
1295         public Name label;
1296         public JCStatement body;
1297         protected JCLabeledStatement(Name label, JCStatement body) {
1298             this.label = label;
1299             this.body = body;
1300         }
1301         @Override
1302         public void accept(Visitor v) { v.visitLabelled(this); }
1303         @DefinedBy(Api.COMPILER_TREE)
1304         public Kind getKind() { return Kind.LABELED_STATEMENT; }
1305         @DefinedBy(Api.COMPILER_TREE)
1306         public Name getLabel() { return label; }
1307         @DefinedBy(Api.COMPILER_TREE)
1308         public JCStatement getStatement() { return body; }
1309         @Override @DefinedBy(Api.COMPILER_TREE)
1310         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1311             return v.visitLabeledStatement(this, d);
1312         }
1313         @Override
1314         public Tag getTag() {
1315             return LABELLED;
1316         }
1317     }
1318 
1319     /**
1320      * A "switch ( ) { }" construction.
1321      */
1322     public static class JCSwitch extends JCStatement implements SwitchTree {
1323         public JCExpression selector;
1324         public List<JCCase> cases;
1325         /** Position of closing brace, optional. */
1326         public int endpos = Position.NOPOS;
1327         public boolean hasTotalPattern;
1328         public boolean patternSwitch;
1329         protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1330             this.selector = selector;
1331             this.cases = cases;
1332         }
1333         @Override
1334         public void accept(Visitor v) { v.visitSwitch(this); }
1335 
1336         @DefinedBy(Api.COMPILER_TREE)
1337         public Kind getKind() { return Kind.SWITCH; }
1338         @DefinedBy(Api.COMPILER_TREE)
1339         public JCExpression getExpression() { return selector; }
1340         @DefinedBy(Api.COMPILER_TREE)
1341         public List<JCCase> getCases() { return cases; }
1342         @Override @DefinedBy(Api.COMPILER_TREE)
1343         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1344             return v.visitSwitch(this, d);
1345         }
1346         @Override
1347         public Tag getTag() {
1348             return SWITCH;
1349         }
1350     }
1351 
1352     /**
1353      * A "case  :" of a switch.
1354      */
1355     public static class JCCase extends JCStatement implements CaseTree {
1356         //as CaseKind is deprecated for removal (as it is part of a preview feature),
1357         //using indirection through these fields to avoid unnecessary @SuppressWarnings:
1358         public static final CaseKind STATEMENT = CaseKind.STATEMENT;
1359         public static final CaseKind RULE = CaseKind.RULE;
1360         public final CaseKind caseKind;
1361         public List<JCCaseLabel> labels;
1362         public List<JCStatement> stats;
1363         public JCTree body;
1364         public boolean completesNormally;
1365         protected JCCase(CaseKind caseKind, List<JCCaseLabel> labels,
1366                          List<JCStatement> stats, JCTree body) {
1367             Assert.checkNonNull(labels);
1368             Assert.check(labels.isEmpty() || labels.head != null);
1369             this.caseKind = caseKind;
1370             this.labels = labels;
1371             this.stats = stats;
1372             this.body = body;
1373         }
1374         @Override
1375         public void accept(Visitor v) { v.visitCase(this); }
1376 
1377         @Override @DefinedBy(Api.COMPILER_TREE)
1378         public Kind getKind() { return Kind.CASE; }
1379         @Override @Deprecated @DefinedBy(Api.COMPILER_TREE)
1380         public JCExpression getExpression() { return getExpressions().head; }
1381         @Override @DefinedBy(Api.COMPILER_TREE)
1382         public List<JCExpression> getExpressions() { return labels.stream().filter(p -> p instanceof JCExpression).map(p -> (JCExpression) p).collect(List.collector()); }
1383         @Override @DefinedBy(Api.COMPILER_TREE)
1384         public List<JCCaseLabel> getLabels() { return labels; }
1385         @Override @DefinedBy(Api.COMPILER_TREE)
1386         public List<JCStatement> getStatements() {
1387             return caseKind == CaseKind.STATEMENT ? stats : null;
1388         }
1389         @Override @DefinedBy(Api.COMPILER_TREE)
1390         public JCTree getBody() { return body; }
1391         @Override @DefinedBy(Api.COMPILER_TREE)
1392         public CaseKind getCaseKind() {
1393             return caseKind;
1394         }
1395         @Override @DefinedBy(Api.COMPILER_TREE)
1396         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1397             return v.visitCase(this, d);
1398         }
1399         @Override
1400         public Tag getTag() {
1401             return CASE;
1402         }
1403     }
1404 
1405     /**
1406      * A "Identifier<TA1, TA2>.default" construction.
1407      */
1408     public static class JCDefaultValue extends JCPolyExpression implements DefaultValueTree {
1409         public JCExpression clazz;
1410 
1411         protected JCDefaultValue(JCExpression clazz) {
1412             this.clazz = clazz;
1413         }
1414         @Override
1415         public void accept(Visitor v) { v.visitDefaultValue(this); }
1416 
1417         @DefinedBy(Api.COMPILER_TREE)
1418         public Kind getKind() { return Kind.DEFAULT_VALUE; }
1419         @Override @DefinedBy(Api.COMPILER_TREE)
1420         public JCExpression getType() { return clazz; }
1421         @Override @DefinedBy(Api.COMPILER_TREE)
1422         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1423             return v.visitDefaultValue(this, d);
1424         }
1425         @Override
1426         public Tag getTag() {
1427             return DEFAULT_VALUE;
1428         }
1429     }
1430 
1431     /**
1432      * A "switch ( ) { }" construction.
1433      */
1434     public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
1435         public JCExpression selector;
1436         public List<JCCase> cases;
1437         /** Position of closing brace, optional. */
1438         public int endpos = Position.NOPOS;
1439         public boolean hasTotalPattern;
1440         public boolean patternSwitch;
1441         protected JCSwitchExpression(JCExpression selector, List<JCCase> cases) {
1442             this.selector = selector;
1443             this.cases = cases;
1444         }
1445         @Override
1446         public void accept(Visitor v) { v.visitSwitchExpression(this); }
1447 
1448         @DefinedBy(Api.COMPILER_TREE)
1449         public Kind getKind() { return Kind.SWITCH_EXPRESSION; }
1450         @DefinedBy(Api.COMPILER_TREE)
1451         public JCExpression getExpression() { return selector; }
1452         @DefinedBy(Api.COMPILER_TREE)
1453         public List<JCCase> getCases() { return cases; }
1454         @Override @DefinedBy(Api.COMPILER_TREE)
1455         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1456             return v.visitSwitchExpression(this, d);
1457         }
1458         @Override
1459         public Tag getTag() {
1460             return SWITCH_EXPRESSION;
1461         }
1462     }
1463 
1464     /**
1465      * A synchronized block.
1466      */
1467     public static class JCSynchronized extends JCStatement implements SynchronizedTree {
1468         public JCExpression lock;
1469         public JCBlock body;
1470         protected JCSynchronized(JCExpression lock, JCBlock body) {
1471             this.lock = lock;
1472             this.body = body;
1473         }
1474         @Override
1475         public void accept(Visitor v) { v.visitSynchronized(this); }
1476 
1477         @DefinedBy(Api.COMPILER_TREE)
1478         public Kind getKind() { return Kind.SYNCHRONIZED; }
1479         @DefinedBy(Api.COMPILER_TREE)
1480         public JCExpression getExpression() { return lock; }
1481         @DefinedBy(Api.COMPILER_TREE)
1482         public JCBlock getBlock() { return body; }
1483         @Override @DefinedBy(Api.COMPILER_TREE)
1484         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1485             return v.visitSynchronized(this, d);
1486         }
1487         @Override
1488         public Tag getTag() {
1489             return SYNCHRONIZED;
1490         }
1491     }
1492 
1493     /**
1494      * A "try { } catch ( ) { } finally { }" block.
1495      */
1496     public static class JCTry extends JCStatement implements TryTree {
1497         public JCBlock body;
1498         public List<JCCatch> catchers;
1499         public JCBlock finalizer;
1500         public List<JCTree> resources;
1501         public boolean finallyCanCompleteNormally;
1502         protected JCTry(List<JCTree> resources,
1503                         JCBlock body,
1504                         List<JCCatch> catchers,
1505                         JCBlock finalizer) {
1506             this.body = body;
1507             this.catchers = catchers;
1508             this.finalizer = finalizer;
1509             this.resources = resources;
1510         }
1511         @Override
1512         public void accept(Visitor v) { v.visitTry(this); }
1513 
1514         @DefinedBy(Api.COMPILER_TREE)
1515         public Kind getKind() { return Kind.TRY; }
1516         @DefinedBy(Api.COMPILER_TREE)
1517         public JCBlock getBlock() { return body; }
1518         @DefinedBy(Api.COMPILER_TREE)
1519         public List<JCCatch> getCatches() {
1520             return catchers;
1521         }
1522         @DefinedBy(Api.COMPILER_TREE)
1523         public JCBlock getFinallyBlock() { return finalizer; }
1524         @Override @DefinedBy(Api.COMPILER_TREE)
1525         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1526             return v.visitTry(this, d);
1527         }
1528         @Override @DefinedBy(Api.COMPILER_TREE)
1529         public List<JCTree> getResources() {
1530             return resources;
1531         }
1532         @Override
1533         public Tag getTag() {
1534             return TRY;
1535         }
1536     }
1537 
1538     /**
1539      * A catch block.
1540      */
1541     public static class JCCatch extends JCTree implements CatchTree {
1542         public JCVariableDecl param;
1543         public JCBlock body;
1544         protected JCCatch(JCVariableDecl param, JCBlock body) {
1545             this.param = param;
1546             this.body = body;
1547         }
1548         @Override
1549         public void accept(Visitor v) { v.visitCatch(this); }
1550 
1551         @DefinedBy(Api.COMPILER_TREE)
1552         public Kind getKind() { return Kind.CATCH; }
1553         @DefinedBy(Api.COMPILER_TREE)
1554         public JCVariableDecl getParameter() { return param; }
1555         @DefinedBy(Api.COMPILER_TREE)
1556         public JCBlock getBlock() { return body; }
1557         @Override @DefinedBy(Api.COMPILER_TREE)
1558         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1559             return v.visitCatch(this, d);
1560         }
1561         @Override
1562         public Tag getTag() {
1563             return CATCH;
1564         }
1565     }
1566 
1567     /**
1568      * A ( ) ? ( ) : ( ) conditional expression
1569      */
1570     public static class JCConditional extends JCPolyExpression implements ConditionalExpressionTree {
1571         public JCExpression cond;
1572         public JCExpression truepart;
1573         public JCExpression falsepart;
1574         protected JCConditional(JCExpression cond,
1575                               JCExpression truepart,
1576                               JCExpression falsepart)
1577         {
1578             this.cond = cond;
1579             this.truepart = truepart;
1580             this.falsepart = falsepart;
1581         }
1582         @Override
1583         public void accept(Visitor v) { v.visitConditional(this); }
1584 
1585         @DefinedBy(Api.COMPILER_TREE)
1586         public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
1587         @DefinedBy(Api.COMPILER_TREE)
1588         public JCExpression getCondition() { return cond; }
1589         @DefinedBy(Api.COMPILER_TREE)
1590         public JCExpression getTrueExpression() { return truepart; }
1591         @DefinedBy(Api.COMPILER_TREE)
1592         public JCExpression getFalseExpression() { return falsepart; }
1593         @Override @DefinedBy(Api.COMPILER_TREE)
1594         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1595             return v.visitConditionalExpression(this, d);
1596         }
1597         @Override
1598         public Tag getTag() {
1599             return CONDEXPR;
1600         }
1601     }
1602 
1603     /**
1604      * An "if ( ) { } else { }" block
1605      */
1606     public static class JCIf extends JCStatement implements IfTree {
1607         public JCExpression cond;
1608         public JCStatement thenpart;
1609         public JCStatement elsepart;
1610         protected JCIf(JCExpression cond,
1611                      JCStatement thenpart,
1612                      JCStatement elsepart)
1613         {
1614             this.cond = cond;
1615             this.thenpart = thenpart;
1616             this.elsepart = elsepart;
1617         }
1618         @Override
1619         public void accept(Visitor v) { v.visitIf(this); }
1620 
1621         @DefinedBy(Api.COMPILER_TREE)
1622         public Kind getKind() { return Kind.IF; }
1623         @DefinedBy(Api.COMPILER_TREE)
1624         public JCExpression getCondition() { return cond; }
1625         @DefinedBy(Api.COMPILER_TREE)
1626         public JCStatement getThenStatement() { return thenpart; }
1627         @DefinedBy(Api.COMPILER_TREE)
1628         public JCStatement getElseStatement() { return elsepart; }
1629         @Override @DefinedBy(Api.COMPILER_TREE)
1630         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1631             return v.visitIf(this, d);
1632         }
1633         @Override
1634         public Tag getTag() {
1635             return IF;
1636         }
1637     }
1638 
1639     /**
1640      * an expression statement
1641      */
1642     public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1643         /** expression structure */
1644         public JCExpression expr;
1645         protected JCExpressionStatement(JCExpression expr)
1646         {
1647             this.expr = expr;
1648         }
1649         @Override
1650         public void accept(Visitor v) { v.visitExec(this); }
1651 
1652         @DefinedBy(Api.COMPILER_TREE)
1653         public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
1654         @DefinedBy(Api.COMPILER_TREE)
1655         public JCExpression getExpression() { return expr; }
1656         @Override @DefinedBy(Api.COMPILER_TREE)
1657         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1658             return v.visitExpressionStatement(this, d);
1659         }
1660         @Override
1661         public Tag getTag() {
1662             return EXEC;
1663         }
1664 
1665         /** Convert a expression-statement tree to a pretty-printed string. */
1666         @Override
1667         public String toString() {
1668             StringWriter s = new StringWriter();
1669             try {
1670                 new Pretty(s, false).printStat(this);
1671             }
1672             catch (IOException e) {
1673                 // should never happen, because StringWriter is defined
1674                 // never to throw any IOExceptions
1675                 throw new AssertionError(e);
1676             }
1677             return s.toString();
1678         }
1679     }
1680 
1681     /**
1682      * A break from a loop or switch.
1683      */
1684     public static class JCBreak extends JCStatement implements BreakTree {
1685         public Name label;
1686         public JCTree target;
1687         protected JCBreak(Name label, JCTree target) {
1688             this.label = label;
1689             this.target = target;
1690         }
1691         @Override
1692         public void accept(Visitor v) { v.visitBreak(this); }
1693         public boolean isValueBreak() {
1694             return target != null && target.hasTag(SWITCH_EXPRESSION);
1695         }
1696 
1697         @DefinedBy(Api.COMPILER_TREE)
1698         public Kind getKind() { return Kind.BREAK; }
1699         @DefinedBy(Api.COMPILER_TREE)
1700         public Name getLabel() {
1701             return label;
1702         }
1703         @Override @DefinedBy(Api.COMPILER_TREE)
1704         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1705             return v.visitBreak(this, d);
1706         }
1707         @Override
1708         public Tag getTag() {
1709             return BREAK;
1710         }
1711     }
1712 
1713     /**
1714      * A break-with from a switch expression.
1715      */
1716     public static class JCYield extends JCStatement implements YieldTree {
1717         public JCExpression value;
1718         public JCTree target;
1719         protected JCYield(JCExpression value, JCTree target) {
1720             this.value = value;
1721             this.target = target;
1722         }
1723         @Override
1724         public void accept(Visitor v) { v.visitYield(this); }
1725         @DefinedBy(Api.COMPILER_TREE)
1726         public Kind getKind() { return Kind.YIELD; }
1727         @DefinedBy(Api.COMPILER_TREE)
1728         public JCExpression getValue() { return value; }
1729         @Override @DefinedBy(Api.COMPILER_TREE)
1730         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1731             return v.visitYield(this, d);
1732         }
1733         @Override
1734         public Tag getTag() {
1735             return YIELD;
1736         }
1737     }
1738 
1739     /**
1740      * A continue of a loop.
1741      */
1742     public static class JCContinue extends JCStatement implements ContinueTree {
1743         public Name label;
1744         public JCTree target;
1745         protected JCContinue(Name label, JCTree target) {
1746             this.label = label;
1747             this.target = target;
1748         }
1749         @Override
1750         public void accept(Visitor v) { v.visitContinue(this); }
1751 
1752         @DefinedBy(Api.COMPILER_TREE)
1753         public Kind getKind() { return Kind.CONTINUE; }
1754         @DefinedBy(Api.COMPILER_TREE)
1755         public Name getLabel() { return label; }
1756         @Override @DefinedBy(Api.COMPILER_TREE)
1757         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1758             return v.visitContinue(this, d);
1759         }
1760         @Override
1761         public Tag getTag() {
1762             return CONTINUE;
1763         }
1764     }
1765 
1766     /**
1767      * A return statement.
1768      */
1769     public static class JCReturn extends JCStatement implements ReturnTree {
1770         public JCExpression expr;
1771         protected JCReturn(JCExpression expr) {
1772             this.expr = expr;
1773         }
1774         @Override
1775         public void accept(Visitor v) { v.visitReturn(this); }
1776 
1777         @DefinedBy(Api.COMPILER_TREE)
1778         public Kind getKind() { return Kind.RETURN; }
1779         @DefinedBy(Api.COMPILER_TREE)
1780         public JCExpression getExpression() { return expr; }
1781         @Override @DefinedBy(Api.COMPILER_TREE)
1782         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1783             return v.visitReturn(this, d);
1784         }
1785         @Override
1786         public Tag getTag() {
1787             return RETURN;
1788         }
1789     }
1790 
1791     /**
1792      * A throw statement.
1793      */
1794     public static class JCThrow extends JCStatement implements ThrowTree {
1795         public JCExpression expr;
1796         protected JCThrow(JCExpression expr) {
1797             this.expr = expr;
1798         }
1799         @Override
1800         public void accept(Visitor v) { v.visitThrow(this); }
1801 
1802         @DefinedBy(Api.COMPILER_TREE)
1803         public Kind getKind() { return Kind.THROW; }
1804         @DefinedBy(Api.COMPILER_TREE)
1805         public JCExpression getExpression() { return expr; }
1806         @Override @DefinedBy(Api.COMPILER_TREE)
1807         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1808             return v.visitThrow(this, d);
1809         }
1810         @Override
1811         public Tag getTag() {
1812             return THROW;
1813         }
1814     }
1815 
1816     /**
1817      * An assert statement.
1818      */
1819     public static class JCAssert extends JCStatement implements AssertTree {
1820         public JCExpression cond;
1821         public JCExpression detail;
1822         protected JCAssert(JCExpression cond, JCExpression detail) {
1823             this.cond = cond;
1824             this.detail = detail;
1825         }
1826         @Override
1827         public void accept(Visitor v) { v.visitAssert(this); }
1828 
1829         @DefinedBy(Api.COMPILER_TREE)
1830         public Kind getKind() { return Kind.ASSERT; }
1831         @DefinedBy(Api.COMPILER_TREE)
1832         public JCExpression getCondition() { return cond; }
1833         @DefinedBy(Api.COMPILER_TREE)
1834         public JCExpression getDetail() { return detail; }
1835         @Override @DefinedBy(Api.COMPILER_TREE)
1836         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1837             return v.visitAssert(this, d);
1838         }
1839         @Override
1840         public Tag getTag() {
1841             return ASSERT;
1842         }
1843     }
1844 
1845     /**
1846      * A method invocation
1847      */
1848     public static class JCMethodInvocation extends JCPolyExpression implements MethodInvocationTree {
1849         public List<JCExpression> typeargs;
1850         public JCExpression meth;
1851         public List<JCExpression> args;
1852         public Type varargsElement;
1853         protected JCMethodInvocation(List<JCExpression> typeargs,
1854                         JCExpression meth,
1855                         List<JCExpression> args)
1856         {
1857             this.typeargs = (typeargs == null) ? List.nil()
1858                                                : typeargs;
1859             this.meth = meth;
1860             this.args = args;
1861         }
1862         @Override
1863         public void accept(Visitor v) { v.visitApply(this); }
1864 
1865         @DefinedBy(Api.COMPILER_TREE)
1866         public Kind getKind() { return Kind.METHOD_INVOCATION; }
1867         @DefinedBy(Api.COMPILER_TREE)
1868         public List<JCExpression> getTypeArguments() {
1869             return typeargs;
1870         }
1871         @DefinedBy(Api.COMPILER_TREE)
1872         public JCExpression getMethodSelect() { return meth; }
1873         @DefinedBy(Api.COMPILER_TREE)
1874         public List<JCExpression> getArguments() {
1875             return args;
1876         }
1877         @Override @DefinedBy(Api.COMPILER_TREE)
1878         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1879             return v.visitMethodInvocation(this, d);
1880         }
1881         @Override
1882         public JCMethodInvocation setType(Type type) {
1883             super.setType(type);
1884             return this;
1885         }
1886         @Override
1887         public Tag getTag() {
1888             return(APPLY);
1889         }
1890     }
1891 
1892     /**
1893      * A new(...) operation.
1894      */
1895     public static class JCNewClass extends JCPolyExpression implements NewClassTree {
1896         public JCExpression encl;
1897         public List<JCExpression> typeargs;
1898         public JCExpression clazz;
1899         public List<JCExpression> args;
1900         public JCClassDecl def;
1901         public Symbol constructor;
1902         public Type varargsElement;
1903         public Type constructorType;
1904         protected JCNewClass(JCExpression encl,
1905                            List<JCExpression> typeargs,
1906                            JCExpression clazz,
1907                            List<JCExpression> args,
1908                            JCClassDecl def)
1909         {
1910             this.encl = encl;
1911             this.typeargs = (typeargs == null) ? List.nil()
1912                                                : typeargs;
1913             this.clazz = clazz;
1914             this.args = args;
1915             this.def = def;
1916         }
1917         @Override
1918         public void accept(Visitor v) { v.visitNewClass(this); }
1919 
1920         @DefinedBy(Api.COMPILER_TREE)
1921         public Kind getKind() { return Kind.NEW_CLASS; }
1922         @DefinedBy(Api.COMPILER_TREE)
1923         public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1924             return encl;
1925         }
1926         @DefinedBy(Api.COMPILER_TREE)
1927         public List<JCExpression> getTypeArguments() {
1928             return typeargs;
1929         }
1930         @DefinedBy(Api.COMPILER_TREE)
1931         public JCExpression getIdentifier() { return clazz; }
1932         @DefinedBy(Api.COMPILER_TREE)
1933         public List<JCExpression> getArguments() {
1934             return args;
1935         }
1936         @DefinedBy(Api.COMPILER_TREE)
1937         public JCClassDecl getClassBody() { return def; }
1938         @Override @DefinedBy(Api.COMPILER_TREE)
1939         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1940             return v.visitNewClass(this, d);
1941         }
1942         @Override
1943         public Tag getTag() {
1944             return NEWCLASS;
1945         }
1946 
1947         public boolean classDeclRemoved() {
1948             return false;
1949         }
1950     }
1951 
1952     /**
1953      * A new[...] operation.
1954      */
1955     public static class JCNewArray extends JCExpression implements NewArrayTree {
1956         public JCExpression elemtype;
1957         public List<JCExpression> dims;
1958         // type annotations on inner-most component
1959         public List<JCAnnotation> annotations;
1960         // type annotations on dimensions
1961         public List<List<JCAnnotation>> dimAnnotations;
1962         public List<JCExpression> elems;
1963         protected JCNewArray(JCExpression elemtype,
1964                            List<JCExpression> dims,
1965                            List<JCExpression> elems)
1966         {
1967             this.elemtype = elemtype;
1968             this.dims = dims;
1969             this.annotations = List.nil();
1970             this.dimAnnotations = List.nil();
1971             this.elems = elems;
1972         }
1973         @Override
1974         public void accept(Visitor v) { v.visitNewArray(this); }
1975 
1976         @DefinedBy(Api.COMPILER_TREE)
1977         public Kind getKind() { return Kind.NEW_ARRAY; }
1978         @DefinedBy(Api.COMPILER_TREE)
1979         public JCExpression getType() { return elemtype; }
1980         @DefinedBy(Api.COMPILER_TREE)
1981         public List<JCExpression> getDimensions() {
1982             return dims;
1983         }
1984         @DefinedBy(Api.COMPILER_TREE)
1985         public List<JCExpression> getInitializers() {
1986             return elems;
1987         }
1988         @Override @DefinedBy(Api.COMPILER_TREE)
1989         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1990             return v.visitNewArray(this, d);
1991         }
1992         @Override
1993         public Tag getTag() {
1994             return NEWARRAY;
1995         }
1996 
1997         @Override @DefinedBy(Api.COMPILER_TREE)
1998         public List<JCAnnotation> getAnnotations() {
1999             return annotations;
2000         }
2001 
2002         @Override @DefinedBy(Api.COMPILER_TREE)
2003         public List<List<JCAnnotation>> getDimAnnotations() {
2004             return dimAnnotations;
2005         }
2006     }
2007 
2008     /**
2009      * A lambda expression.
2010      */
2011     public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2012 
2013         public enum ParameterKind {
2014             IMPLICIT,
2015             EXPLICIT
2016         }
2017 
2018         public List<JCVariableDecl> params;
2019         public JCTree body;
2020         public boolean canCompleteNormally = true;
2021         public ParameterKind paramKind;
2022 
2023         public JCLambda(List<JCVariableDecl> params,
2024                         JCTree body) {
2025             this.params = params;
2026             this.body = body;
2027             if (params.isEmpty() ||
2028                 params.head.vartype != null) {
2029                 paramKind = ParameterKind.EXPLICIT;
2030             } else {
2031                 paramKind = ParameterKind.IMPLICIT;
2032             }
2033         }
2034         @Override
2035         public Tag getTag() {
2036             return LAMBDA;
2037         }
2038         @Override
2039         public void accept(Visitor v) {
2040             v.visitLambda(this);
2041         }
2042         @Override @DefinedBy(Api.COMPILER_TREE)
2043         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2044             return v.visitLambdaExpression(this, d);
2045         }
2046         @DefinedBy(Api.COMPILER_TREE)
2047         public Kind getKind() {
2048             return Kind.LAMBDA_EXPRESSION;
2049         }
2050         @DefinedBy(Api.COMPILER_TREE)
2051         public JCTree getBody() {
2052             return body;
2053         }
2054         @DefinedBy(Api.COMPILER_TREE)
2055         public java.util.List<? extends VariableTree> getParameters() {
2056             return params;
2057         }
2058         @Override
2059         public JCLambda setType(Type type) {
2060             super.setType(type);
2061             return this;
2062         }
2063         @Override @DefinedBy(Api.COMPILER_TREE)
2064         public BodyKind getBodyKind() {
2065             return body.hasTag(BLOCK) ?
2066                     BodyKind.STATEMENT :
2067                     BodyKind.EXPRESSION;
2068         }
2069     }
2070 
2071     /**
2072      * A parenthesized subexpression ( ... )
2073      */
2074     public static class JCParens extends JCExpression implements ParenthesizedTree {
2075         public JCExpression expr;
2076         protected JCParens(JCExpression expr) {
2077             this.expr = expr;
2078         }
2079         @Override
2080         public void accept(Visitor v) { v.visitParens(this); }
2081 
2082         @DefinedBy(Api.COMPILER_TREE)
2083         public Kind getKind() { return Kind.PARENTHESIZED; }
2084         @DefinedBy(Api.COMPILER_TREE)
2085         public JCExpression getExpression() { return expr; }
2086         @Override @DefinedBy(Api.COMPILER_TREE)
2087         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2088             return v.visitParenthesized(this, d);
2089         }
2090         @Override
2091         public Tag getTag() {
2092             return PARENS;
2093         }
2094     }
2095 
2096     /**
2097      * A assignment with "=".
2098      */
2099     public static class JCAssign extends JCExpression implements AssignmentTree {
2100         public JCExpression lhs;
2101         public JCExpression rhs;
2102         protected JCAssign(JCExpression lhs, JCExpression rhs) {
2103             this.lhs = lhs;
2104             this.rhs = rhs;
2105         }
2106         @Override
2107         public void accept(Visitor v) { v.visitAssign(this); }
2108 
2109         @DefinedBy(Api.COMPILER_TREE)
2110         public Kind getKind() { return Kind.ASSIGNMENT; }
2111         @DefinedBy(Api.COMPILER_TREE)
2112         public JCExpression getVariable() { return lhs; }
2113         @DefinedBy(Api.COMPILER_TREE)
2114         public JCExpression getExpression() { return rhs; }
2115         @Override @DefinedBy(Api.COMPILER_TREE)
2116         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2117             return v.visitAssignment(this, d);
2118         }
2119         @Override
2120         public Tag getTag() {
2121             return ASSIGN;
2122         }
2123     }
2124 
2125     public static abstract class JCOperatorExpression extends JCExpression {
2126         public enum OperandPos {
2127             LEFT,
2128             RIGHT
2129         }
2130 
2131         protected Tag opcode;
2132         public OperatorSymbol operator;
2133 
2134         public OperatorSymbol getOperator() {
2135             return operator;
2136         }
2137 
2138         @Override
2139         public Tag getTag() {
2140             return opcode;
2141         }
2142 
2143         public abstract JCExpression getOperand(OperandPos pos);
2144     }
2145 
2146     /**
2147      * An assignment with "+=", "|=" ...
2148      */
2149     public static class JCAssignOp extends JCOperatorExpression implements CompoundAssignmentTree {
2150         public JCExpression lhs;
2151         public JCExpression rhs;
2152         protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, OperatorSymbol operator) {
2153             this.opcode = opcode;
2154             this.lhs = (JCExpression)lhs;
2155             this.rhs = (JCExpression)rhs;
2156             this.operator = operator;
2157         }
2158         @Override
2159         public void accept(Visitor v) { v.visitAssignop(this); }
2160 
2161         @DefinedBy(Api.COMPILER_TREE)
2162         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2163         @DefinedBy(Api.COMPILER_TREE)
2164         public JCExpression getVariable() { return lhs; }
2165         @DefinedBy(Api.COMPILER_TREE)
2166         public JCExpression getExpression() { return rhs; }
2167         @Override @DefinedBy(Api.COMPILER_TREE)
2168         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2169             return v.visitCompoundAssignment(this, d);
2170         }
2171         @Override
2172         public JCExpression getOperand(OperandPos pos) {
2173             return pos == OperandPos.LEFT ? lhs : rhs;
2174         }
2175     }
2176 
2177     /**
2178      * A unary operation.
2179      */
2180     public static class JCUnary extends JCOperatorExpression implements UnaryTree {
2181         public JCExpression arg;
2182         protected JCUnary(Tag opcode, JCExpression arg) {
2183             this.opcode = opcode;
2184             this.arg = arg;
2185         }
2186         @Override
2187         public void accept(Visitor v) { v.visitUnary(this); }
2188 
2189         @DefinedBy(Api.COMPILER_TREE)
2190         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2191         @DefinedBy(Api.COMPILER_TREE)
2192         public JCExpression getExpression() { return arg; }
2193         @Override @DefinedBy(Api.COMPILER_TREE)
2194         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2195             return v.visitUnary(this, d);
2196         }
2197         public void setTag(Tag tag) {
2198             opcode = tag;
2199         }
2200         @Override
2201         public JCExpression getOperand(OperandPos pos) {
2202             return arg;
2203         }
2204     }
2205 
2206     /**
2207      * A binary operation.
2208      */
2209     public static class JCBinary extends JCOperatorExpression implements BinaryTree {
2210         public JCExpression lhs;
2211         public JCExpression rhs;
2212         protected JCBinary(Tag opcode,
2213                          JCExpression lhs,
2214                          JCExpression rhs,
2215                          OperatorSymbol operator) {
2216             this.opcode = opcode;
2217             this.lhs = lhs;
2218             this.rhs = rhs;
2219             this.operator = operator;
2220         }
2221         @Override
2222         public void accept(Visitor v) { v.visitBinary(this); }
2223 
2224         @DefinedBy(Api.COMPILER_TREE)
2225         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2226         @DefinedBy(Api.COMPILER_TREE)
2227         public JCExpression getLeftOperand() { return lhs; }
2228         @DefinedBy(Api.COMPILER_TREE)
2229         public JCExpression getRightOperand() { return rhs; }
2230         @Override @DefinedBy(Api.COMPILER_TREE)
2231         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2232             return v.visitBinary(this, d);
2233         }
2234         @Override
2235         public JCExpression getOperand(OperandPos pos) {
2236             return pos == OperandPos.LEFT ? lhs : rhs;
2237         }
2238     }
2239 
2240     /**
2241      * A type cast.
2242      */
2243     public static class JCTypeCast extends JCExpression implements TypeCastTree {
2244         public JCTree clazz;
2245         public JCExpression expr;
2246         protected JCTypeCast(JCTree clazz, JCExpression expr) {
2247             this.clazz = clazz;
2248             this.expr = expr;
2249         }
2250         @Override
2251         public void accept(Visitor v) { v.visitTypeCast(this); }
2252 
2253         @DefinedBy(Api.COMPILER_TREE)
2254         public Kind getKind() { return Kind.TYPE_CAST; }
2255         @DefinedBy(Api.COMPILER_TREE)
2256         public JCTree getType() { return clazz; }
2257         @DefinedBy(Api.COMPILER_TREE)
2258         public JCExpression getExpression() { return expr; }
2259         @Override @DefinedBy(Api.COMPILER_TREE)
2260         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2261             return v.visitTypeCast(this, d);
2262         }
2263         @Override
2264         public Tag getTag() {
2265             return TYPECAST;
2266         }
2267     }
2268 
2269     /**
2270      * A type test.
2271      */
2272     public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
2273         public JCExpression expr;
2274         public JCTree pattern;
2275         protected JCInstanceOf(JCExpression expr, JCTree pattern) {
2276             this.expr = expr;
2277             this.pattern = pattern;
2278         }
2279         @Override
2280         public void accept(Visitor v) { v.visitTypeTest(this); }
2281 
2282         @DefinedBy(Api.COMPILER_TREE)
2283         public Kind getKind() { return Kind.INSTANCE_OF; }
2284         @DefinedBy(Api.COMPILER_TREE)
2285         public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).var.vartype : null : pattern; }
2286 
2287         @Override @DefinedBy(Api.COMPILER_TREE)
2288         public JCPattern getPattern() {
2289             return pattern instanceof JCPattern jcPattern ? jcPattern : null;
2290         }
2291 
2292         @DefinedBy(Api.COMPILER_TREE)
2293         public JCExpression getExpression() { return expr; }
2294         @Override @DefinedBy(Api.COMPILER_TREE)
2295         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2296             return v.visitInstanceOf(this, d);
2297         }
2298         @Override
2299         public Tag getTag() {
2300             return TYPETEST;
2301         }
2302     }
2303 
2304     /**
2305      * Pattern matching forms.
2306      */
2307     public static abstract class JCPattern extends JCCaseLabel
2308             implements PatternTree {
2309 
2310         @Override
2311         public boolean isExpression() {
2312             return false;
2313         }
2314 
2315         @Override
2316         public boolean isPattern() {
2317             return true;
2318         }
2319     }
2320 
2321     public static class JCBindingPattern extends JCPattern
2322             implements BindingPatternTree {
2323         public JCVariableDecl var;
2324 
2325         protected JCBindingPattern(JCVariableDecl var) {
2326             this.var = var;
2327         }
2328 
2329         @Override @DefinedBy(Api.COMPILER_TREE)
2330         public VariableTree getVariable() {
2331             return var;
2332         }
2333 
2334         @Override
2335         public void accept(Visitor v) {
2336             v.visitBindingPattern(this);
2337         }
2338 
2339         @DefinedBy(Api.COMPILER_TREE)
2340         public Kind getKind() {
2341             return Kind.BINDING_PATTERN;
2342         }
2343 
2344         @Override
2345         @DefinedBy(Api.COMPILER_TREE)
2346         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2347             return v.visitBindingPattern(this, d);
2348         }
2349 
2350         @Override
2351         public Tag getTag() {
2352             return BINDINGPATTERN;
2353         }
2354     }
2355 
2356     public static class JCDefaultCaseLabel extends JCCaseLabel
2357             implements DefaultCaseLabelTree {
2358 
2359         protected JCDefaultCaseLabel() {
2360         }
2361 
2362         @Override
2363         public void accept(Visitor v) {
2364             v.visitDefaultCaseLabel(this);
2365         }
2366 
2367         @DefinedBy(Api.COMPILER_TREE)
2368         public Kind getKind() {
2369             return Kind.DEFAULT_CASE_LABEL;
2370         }
2371 
2372         @Override
2373         @DefinedBy(Api.COMPILER_TREE)
2374         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2375             return v.visitDefaultCaseLabel(this, d);
2376         }
2377 
2378         @Override
2379         public Tag getTag() {
2380             return DEFAULTCASELABEL;
2381         }
2382 
2383         @Override
2384         public boolean isExpression() {
2385             return false;
2386         }
2387 
2388         @Override
2389         public boolean isPattern() {
2390             return false;
2391         }
2392     }
2393 
2394     public static class JCParenthesizedPattern extends JCPattern
2395             implements ParenthesizedPatternTree {
2396         public JCPattern pattern;
2397 
2398         public JCParenthesizedPattern(JCPattern pattern) {
2399             this.pattern = pattern;
2400         }
2401 
2402         @Override @DefinedBy(Api.COMPILER_TREE)
2403         public PatternTree getPattern() {
2404             return pattern;
2405         }
2406 
2407         @Override
2408         public void accept(Visitor v) {
2409             v.visitParenthesizedPattern(this);
2410         }
2411 
2412         @DefinedBy(Api.COMPILER_TREE)
2413         public Kind getKind() {
2414             return Kind.PARENTHESIZED_PATTERN;
2415         }
2416 
2417         @Override
2418         @DefinedBy(Api.COMPILER_TREE)
2419         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2420             return v.visitParenthesizedPattern(this, d);
2421         }
2422 
2423         @Override
2424         public Tag getTag() {
2425             return PARENTHESIZEDPATTERN;
2426         }
2427     }
2428 
2429     public static class JCGuardPattern extends JCPattern
2430             implements GuardedPatternTree {
2431         public JCPattern patt;
2432         public JCExpression expr;
2433 
2434         public JCGuardPattern(JCPattern patt, JCExpression expr) {
2435             this.patt = patt;
2436             this.expr = expr;
2437         }
2438 
2439         @Override @DefinedBy(Api.COMPILER_TREE)
2440         public PatternTree getPattern() {
2441             return patt;
2442         }
2443 
2444         @Override @DefinedBy(Api.COMPILER_TREE)
2445         public ExpressionTree getExpression() {
2446             return expr;
2447         }
2448 
2449         @Override
2450         public void accept(Visitor v) {
2451             v.visitGuardPattern(this);
2452         }
2453 
2454         @DefinedBy(Api.COMPILER_TREE)
2455         public Kind getKind() {
2456             return Kind.GUARDED_PATTERN;
2457         }
2458 
2459         @Override
2460         @DefinedBy(Api.COMPILER_TREE)
2461         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2462             return v.visitGuardedPattern(this, d);
2463         }
2464 
2465         @Override
2466         public Tag getTag() {
2467             return Tag.GUARDPATTERN;
2468         }
2469     }
2470 
2471     /**
2472      * An array selection
2473      */
2474     public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
2475         public JCExpression indexed;
2476         public JCExpression index;
2477         protected JCArrayAccess(JCExpression indexed, JCExpression index) {
2478             this.indexed = indexed;
2479             this.index = index;
2480         }
2481         @Override
2482         public void accept(Visitor v) { v.visitIndexed(this); }
2483 
2484         @DefinedBy(Api.COMPILER_TREE)
2485         public Kind getKind() { return Kind.ARRAY_ACCESS; }
2486         @DefinedBy(Api.COMPILER_TREE)
2487         public JCExpression getExpression() { return indexed; }
2488         @DefinedBy(Api.COMPILER_TREE)
2489         public JCExpression getIndex() { return index; }
2490         @Override @DefinedBy(Api.COMPILER_TREE)
2491         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2492             return v.visitArrayAccess(this, d);
2493         }
2494         @Override
2495         public Tag getTag() {
2496             return INDEXED;
2497         }
2498     }
2499 
2500     /**
2501      * Selects through packages and classes
2502      */
2503     public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
2504         /** selected Tree hierarchy */
2505         public JCExpression selected;
2506         /** name of field to select thru */
2507         public Name name;
2508         /** symbol of the selected class */
2509         public Symbol sym;
2510         protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
2511             this.selected = selected;
2512             this.name = name;
2513             this.sym = sym;
2514         }
2515         @Override
2516         public void accept(Visitor v) { v.visitSelect(this); }
2517 
2518         @DefinedBy(Api.COMPILER_TREE)
2519         public Kind getKind() { return Kind.MEMBER_SELECT; }
2520         @DefinedBy(Api.COMPILER_TREE)
2521         public JCExpression getExpression() { return selected; }
2522         @Override @DefinedBy(Api.COMPILER_TREE)
2523         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2524             return v.visitMemberSelect(this, d);
2525         }
2526         @DefinedBy(Api.COMPILER_TREE)
2527         public Name getIdentifier() { return name; }
2528         @Override
2529         public Tag getTag() {
2530             return SELECT;
2531         }
2532     }
2533 
2534     /**
2535      * Selects a member expression.
2536      */
2537     public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2538 
2539         public ReferenceMode mode;
2540         public ReferenceKind kind;
2541         public Name name;
2542         public JCExpression expr;
2543         public List<JCExpression> typeargs;
2544         public Symbol sym;
2545         public Type varargsElement;
2546         public PolyKind refPolyKind;
2547         public boolean ownerAccessible;
2548         private OverloadKind overloadKind;
2549         public Type referentType;
2550 
2551         public enum OverloadKind {
2552             OVERLOADED,
2553             UNOVERLOADED,
2554             ERROR
2555         }
2556 
2557         /**
2558          * Javac-dependent classification for member references, based
2559          * on relevant properties w.r.t. code-generation
2560          */
2561         public enum ReferenceKind {
2562             /** super # instMethod */
2563             SUPER(ReferenceMode.INVOKE, false),
2564             /** Type # instMethod */
2565             UNBOUND(ReferenceMode.INVOKE, true),
2566             /** Type # staticMethod */
2567             STATIC(ReferenceMode.INVOKE, false),
2568             /** Expr # instMethod */
2569             BOUND(ReferenceMode.INVOKE, false),
2570             /** Inner # new */
2571             IMPLICIT_INNER(ReferenceMode.NEW, false),
2572             /** Toplevel # new */
2573             TOPLEVEL(ReferenceMode.NEW, false),
2574             /** ArrayType # new */
2575             ARRAY_CTOR(ReferenceMode.NEW, false);
2576 
2577             final ReferenceMode mode;
2578             final boolean unbound;
2579 
2580             private ReferenceKind(ReferenceMode mode, boolean unbound) {
2581                 this.mode = mode;
2582                 this.unbound = unbound;
2583             }
2584 
2585             public boolean isUnbound() {
2586                 return unbound;
2587             }
2588         }
2589 
2590         public JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
2591             this.mode = mode;
2592             this.name = name;
2593             this.expr = expr;
2594             this.typeargs = typeargs;
2595         }
2596         @Override
2597         public void accept(Visitor v) { v.visitReference(this); }
2598 
2599         @DefinedBy(Api.COMPILER_TREE)
2600         public Kind getKind() { return Kind.MEMBER_REFERENCE; }
2601         @Override @DefinedBy(Api.COMPILER_TREE)
2602         public ReferenceMode getMode() { return mode; }
2603         @Override @DefinedBy(Api.COMPILER_TREE)
2604         public JCExpression getQualifierExpression() { return expr; }
2605         @Override @DefinedBy(Api.COMPILER_TREE)
2606         public Name getName() { return name; }
2607         @Override @DefinedBy(Api.COMPILER_TREE)
2608         public List<JCExpression> getTypeArguments() { return typeargs; }
2609 
2610         @Override @DefinedBy(Api.COMPILER_TREE)
2611         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2612             return v.visitMemberReference(this, d);
2613         }
2614         @Override
2615         public Tag getTag() {
2616             return REFERENCE;
2617         }
2618         public boolean hasKind(ReferenceKind kind) {
2619             return this.kind == kind;
2620         }
2621 
2622         /**
2623          * @return the overloadKind
2624          */
2625         public OverloadKind getOverloadKind() {
2626             return overloadKind;
2627         }
2628 
2629         /**
2630          * @param overloadKind the overloadKind to set
2631          */
2632         public void setOverloadKind(OverloadKind overloadKind) {
2633             this.overloadKind = overloadKind;
2634         }
2635     }
2636 
2637     /**
2638      * An identifier
2639      */
2640     public static class JCIdent extends JCExpression implements IdentifierTree {
2641         /** the name */
2642         public Name name;
2643         /** the symbol */
2644         public Symbol sym;
2645         protected JCIdent(Name name, Symbol sym) {
2646             this.name = name;
2647             this.sym = sym;
2648         }
2649         @Override
2650         public void accept(Visitor v) { v.visitIdent(this); }
2651 
2652         @DefinedBy(Api.COMPILER_TREE)
2653         public Kind getKind() { return Kind.IDENTIFIER; }
2654         @DefinedBy(Api.COMPILER_TREE)
2655         public Name getName() { return name; }
2656         @Override @DefinedBy(Api.COMPILER_TREE)
2657         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2658             return v.visitIdentifier(this, d);
2659         }
2660         @Override
2661         public Tag getTag() {
2662             return IDENT;
2663         }
2664     }
2665 
2666     /**
2667      * A constant value given literally.
2668      */
2669     public static class JCLiteral extends JCExpression implements LiteralTree {
2670         public TypeTag typetag;
2671         /** value representation */
2672         public Object value;
2673         protected JCLiteral(TypeTag typetag, Object value) {
2674             this.typetag = typetag;
2675             this.value = value;
2676         }
2677         @Override
2678         public void accept(Visitor v) { v.visitLiteral(this); }
2679 
2680         @DefinedBy(Api.COMPILER_TREE)
2681         public Kind getKind() {
2682             return typetag.getKindLiteral();
2683         }
2684 
2685         @DefinedBy(Api.COMPILER_TREE)
2686         public Object getValue() {
2687             switch (typetag) {
2688                 case BOOLEAN:
2689                     int bi = (Integer) value;
2690                     return (bi != 0);
2691                 case CHAR:
2692                     int ci = (Integer) value;
2693                     char c = (char) ci;
2694                     if (c != ci)
2695                         throw new AssertionError("bad value for char literal");
2696                     return c;
2697                 default:
2698                     return value;
2699             }
2700         }
2701         @Override @DefinedBy(Api.COMPILER_TREE)
2702         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2703             return v.visitLiteral(this, d);
2704         }
2705         @Override
2706         public JCLiteral setType(Type type) {
2707             super.setType(type);
2708             return this;
2709         }
2710         @Override
2711         public Tag getTag() {
2712             return LITERAL;
2713         }
2714     }
2715 
2716     /**
2717      * Identifies a basic type.
2718      * @see TypeTag
2719      */
2720     public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
2721         /** the basic type id */
2722         public TypeTag typetag;
2723         protected JCPrimitiveTypeTree(TypeTag typetag) {
2724             this.typetag = typetag;
2725         }
2726         @Override
2727         public void accept(Visitor v) { v.visitTypeIdent(this); }
2728 
2729         @DefinedBy(Api.COMPILER_TREE)
2730         public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
2731         @DefinedBy(Api.COMPILER_TREE)
2732         public TypeKind getPrimitiveTypeKind() {
2733             return typetag.getPrimitiveTypeKind();
2734         }
2735 
2736         @Override @DefinedBy(Api.COMPILER_TREE)
2737         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2738             return v.visitPrimitiveType(this, d);
2739         }
2740         @Override
2741         public Tag getTag() {
2742             return TYPEIDENT;
2743         }
2744     }
2745 
2746     /**
2747      * An array type, A[]
2748      */
2749     public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
2750         public JCExpression elemtype;
2751         protected JCArrayTypeTree(JCExpression elemtype) {
2752             this.elemtype = elemtype;
2753         }
2754         @Override
2755         public void accept(Visitor v) { v.visitTypeArray(this); }
2756 
2757         @DefinedBy(Api.COMPILER_TREE)
2758         public Kind getKind() { return Kind.ARRAY_TYPE; }
2759         @DefinedBy(Api.COMPILER_TREE)
2760         public JCTree getType() { return elemtype; }
2761         @Override @DefinedBy(Api.COMPILER_TREE)
2762         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2763             return v.visitArrayType(this, d);
2764         }
2765         @Override
2766         public Tag getTag() {
2767             return TYPEARRAY;
2768         }
2769     }
2770 
2771     /**
2772      * A parameterized type, {@literal T<...>}
2773      */
2774     public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
2775         public JCExpression clazz;
2776         public List<JCExpression> arguments;
2777         protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
2778             this.clazz = clazz;
2779             this.arguments = arguments;
2780         }
2781         @Override
2782         public void accept(Visitor v) { v.visitTypeApply(this); }
2783 
2784         @DefinedBy(Api.COMPILER_TREE)
2785         public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
2786         @DefinedBy(Api.COMPILER_TREE)
2787         public JCTree getType() { return clazz; }
2788         @DefinedBy(Api.COMPILER_TREE)
2789         public List<JCExpression> getTypeArguments() {
2790             return arguments;
2791         }
2792         @Override @DefinedBy(Api.COMPILER_TREE)
2793         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2794             return v.visitParameterizedType(this, d);
2795         }
2796         @Override
2797         public Tag getTag() {
2798             return TYPEAPPLY;
2799         }
2800     }
2801 
2802     /**
2803      * A union type, T1 | T2 | ... Tn (used in multicatch statements)
2804      */
2805     public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
2806 
2807         public List<JCExpression> alternatives;
2808 
2809         protected JCTypeUnion(List<JCExpression> components) {
2810             this.alternatives = components;
2811         }
2812         @Override
2813         public void accept(Visitor v) { v.visitTypeUnion(this); }
2814 
2815         @DefinedBy(Api.COMPILER_TREE)
2816         public Kind getKind() { return Kind.UNION_TYPE; }
2817 
2818         @DefinedBy(Api.COMPILER_TREE)
2819         public List<JCExpression> getTypeAlternatives() {
2820             return alternatives;
2821         }
2822         @Override @DefinedBy(Api.COMPILER_TREE)
2823         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2824             return v.visitUnionType(this, d);
2825         }
2826         @Override
2827         public Tag getTag() {
2828             return TYPEUNION;
2829         }
2830     }
2831 
2832     /**
2833      * An intersection type, {@code T1 & T2 & ... Tn} (used in cast expressions)
2834      */
2835     public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree {
2836 
2837         public List<JCExpression> bounds;
2838 
2839         protected JCTypeIntersection(List<JCExpression> bounds) {
2840             this.bounds = bounds;
2841         }
2842         @Override
2843         public void accept(Visitor v) { v.visitTypeIntersection(this); }
2844 
2845         @DefinedBy(Api.COMPILER_TREE)
2846         public Kind getKind() { return Kind.INTERSECTION_TYPE; }
2847 
2848         @DefinedBy(Api.COMPILER_TREE)
2849         public List<JCExpression> getBounds() {
2850             return bounds;
2851         }
2852         @Override @DefinedBy(Api.COMPILER_TREE)
2853         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2854             return v.visitIntersectionType(this, d);
2855         }
2856         @Override
2857         public Tag getTag() {
2858             return TYPEINTERSECTION;
2859         }
2860     }
2861 
2862     /**
2863      * A formal class parameter.
2864      */
2865     public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2866         /** name */
2867         public Name name;
2868         /** bounds */
2869         public List<JCExpression> bounds;
2870         /** type annotations on type parameter */
2871         public List<JCAnnotation> annotations;
2872         protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) {
2873             this.name = name;
2874             this.bounds = bounds;
2875             this.annotations = annotations;
2876         }
2877         @Override
2878         public void accept(Visitor v) { v.visitTypeParameter(this); }
2879 
2880         @DefinedBy(Api.COMPILER_TREE)
2881         public Kind getKind() { return Kind.TYPE_PARAMETER; }
2882         @DefinedBy(Api.COMPILER_TREE)
2883         public Name getName() { return name; }
2884         @DefinedBy(Api.COMPILER_TREE)
2885         public List<JCExpression> getBounds() {
2886             return bounds;
2887         }
2888         @DefinedBy(Api.COMPILER_TREE)
2889         public List<JCAnnotation> getAnnotations() {
2890             return annotations;
2891         }
2892         @Override @DefinedBy(Api.COMPILER_TREE)
2893         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2894             return v.visitTypeParameter(this, d);
2895         }
2896         @Override
2897         public Tag getTag() {
2898             return TYPEPARAMETER;
2899         }
2900     }
2901 
2902     public static class JCWildcard extends JCExpression implements WildcardTree {
2903         public TypeBoundKind kind;
2904         public JCTree inner;
2905         protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2906             this.kind = Assert.checkNonNull(kind);
2907             this.inner = inner;
2908         }
2909         @Override
2910         public void accept(Visitor v) { v.visitWildcard(this); }
2911 
2912         @DefinedBy(Api.COMPILER_TREE)
2913         public Kind getKind() {
2914             switch (kind.kind) {
2915             case UNBOUND:
2916                 return Kind.UNBOUNDED_WILDCARD;
2917             case EXTENDS:
2918                 return Kind.EXTENDS_WILDCARD;
2919             case SUPER:
2920                 return Kind.SUPER_WILDCARD;
2921             default:
2922                 throw new AssertionError("Unknown wildcard bound " + kind);
2923             }
2924         }
2925         @DefinedBy(Api.COMPILER_TREE)
2926         public JCTree getBound() { return inner; }
2927         @Override @DefinedBy(Api.COMPILER_TREE)
2928         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2929             return v.visitWildcard(this, d);
2930         }
2931         @Override
2932         public Tag getTag() {
2933             return Tag.WILDCARD;
2934         }
2935     }
2936 
2937     public static class TypeBoundKind extends JCTree {
2938         public BoundKind kind;
2939         protected TypeBoundKind(BoundKind kind) {
2940             this.kind = kind;
2941         }
2942         @Override
2943         public void accept(Visitor v) { v.visitTypeBoundKind(this); }
2944 
2945         @DefinedBy(Api.COMPILER_TREE)
2946         public Kind getKind() {
2947             throw new AssertionError("TypeBoundKind is not part of a public API");
2948         }
2949         @Override @DefinedBy(Api.COMPILER_TREE)
2950         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2951             throw new AssertionError("TypeBoundKind is not part of a public API");
2952         }
2953         @Override
2954         public Tag getTag() {
2955             return TYPEBOUNDKIND;
2956         }
2957     }
2958 
2959     public static class JCAnnotation extends JCExpression implements AnnotationTree {
2960         // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION
2961         private Tag tag;
2962 
2963         public JCTree annotationType;
2964         public List<JCExpression> args;
2965         public Attribute.Compound attribute;
2966 
2967         protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
2968             this.tag = tag;
2969             this.annotationType = annotationType;
2970             this.args = args;
2971         }
2972 
2973         @Override
2974         public void accept(Visitor v) { v.visitAnnotation(this); }
2975 
2976         @DefinedBy(Api.COMPILER_TREE)
2977         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2978 
2979         @DefinedBy(Api.COMPILER_TREE)
2980         public JCTree getAnnotationType() { return annotationType; }
2981         @DefinedBy(Api.COMPILER_TREE)
2982         public List<JCExpression> getArguments() {
2983             return args;
2984         }
2985         @Override @DefinedBy(Api.COMPILER_TREE)
2986         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2987             return v.visitAnnotation(this, d);
2988         }
2989         @Override
2990         public Tag getTag() {
2991             return tag;
2992         }
2993     }
2994 
2995     public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
2996         public long flags;
2997         public List<JCAnnotation> annotations;
2998         protected JCModifiers(long flags, List<JCAnnotation> annotations) {
2999             this.flags = flags;
3000             this.annotations = annotations;
3001         }
3002         @Override
3003         public void accept(Visitor v) { v.visitModifiers(this); }
3004 
3005         @DefinedBy(Api.COMPILER_TREE)
3006         public Kind getKind() { return Kind.MODIFIERS; }
3007         @DefinedBy(Api.COMPILER_TREE)
3008         public Set<Modifier> getFlags() {
3009             return Flags.asModifierSet(flags);
3010         }
3011         @DefinedBy(Api.COMPILER_TREE)
3012         public List<JCAnnotation> getAnnotations() {
3013             return annotations;
3014         }
3015         @Override @DefinedBy(Api.COMPILER_TREE)
3016         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3017             return v.visitModifiers(this, d);
3018         }
3019         @Override
3020         public Tag getTag() {
3021             return MODIFIERS;
3022         }
3023     }
3024 
3025     public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
3026         // type annotations
3027         public List<JCAnnotation> annotations;
3028         public JCExpression underlyingType;
3029 
3030         protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
3031             Assert.check(annotations != null && annotations.nonEmpty());
3032             this.annotations = annotations;
3033             this.underlyingType = underlyingType;
3034         }
3035         @Override
3036         public void accept(Visitor v) { v.visitAnnotatedType(this); }
3037 
3038         @DefinedBy(Api.COMPILER_TREE)
3039         public Kind getKind() { return Kind.ANNOTATED_TYPE; }
3040         @DefinedBy(Api.COMPILER_TREE)
3041         public List<JCAnnotation> getAnnotations() {
3042             return annotations;
3043         }
3044         @DefinedBy(Api.COMPILER_TREE)
3045         public JCExpression getUnderlyingType() {
3046             return underlyingType;
3047         }
3048         @Override @DefinedBy(Api.COMPILER_TREE)
3049         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3050             return v.visitAnnotatedType(this, d);
3051         }
3052         @Override
3053         public Tag getTag() {
3054             return ANNOTATED_TYPE;
3055         }
3056     }
3057 
3058     public static abstract class JCDirective extends JCTree
3059         implements DirectiveTree {
3060     }
3061 
3062     public static class JCModuleDecl extends JCTree implements ModuleTree {
3063         public JCModifiers mods;
3064         public ModuleType type;
3065         private final ModuleKind kind;
3066         public JCExpression qualId;
3067         public List<JCDirective> directives;
3068         public ModuleSymbol sym;
3069 
3070         protected JCModuleDecl(JCModifiers mods, ModuleKind kind,
3071                 JCExpression qualId, List<JCDirective> directives) {
3072             this.mods = mods;
3073             this.kind = kind;
3074             this.qualId = qualId;
3075             this.directives = directives;
3076         }
3077 
3078         @Override
3079         public void accept(Visitor v) { v.visitModuleDef(this); }
3080 
3081         @Override @DefinedBy(Api.COMPILER_TREE)
3082         public Kind getKind() {
3083             return Kind.MODULE;
3084         }
3085 
3086         @Override @DefinedBy(Api.COMPILER_TREE)
3087         public List<? extends AnnotationTree> getAnnotations() {
3088             return mods.annotations;
3089         }
3090 
3091         @Override @DefinedBy(Api.COMPILER_TREE)
3092         public ModuleKind getModuleType() {
3093             return kind;
3094         }
3095 
3096         @Override @DefinedBy(Api.COMPILER_TREE)
3097         public JCExpression getName() {
3098             return qualId;
3099         }
3100 
3101         @Override @DefinedBy(Api.COMPILER_TREE)
3102         public List<JCDirective> getDirectives() {
3103             return directives;
3104         }
3105 
3106         @Override @DefinedBy(Api.COMPILER_TREE)
3107         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3108             return v.visitModule(this, d);
3109         }
3110 
3111         @Override
3112         public Tag getTag() {
3113             return MODULEDEF;
3114         }
3115     }
3116 
3117     public static class JCExports extends JCDirective
3118             implements ExportsTree {
3119         public JCExpression qualid;
3120         public List<JCExpression> moduleNames;
3121         public ExportsDirective directive;
3122 
3123         protected JCExports(JCExpression qualId, List<JCExpression> moduleNames) {
3124             this.qualid = qualId;
3125             this.moduleNames = moduleNames;
3126         }
3127 
3128         @Override
3129         public void accept(Visitor v) { v.visitExports(this); }
3130 
3131         @Override @DefinedBy(Api.COMPILER_TREE)
3132         public Kind getKind() {
3133             return Kind.EXPORTS;
3134         }
3135 
3136         @Override @DefinedBy(Api.COMPILER_TREE)
3137         public JCExpression getPackageName() {
3138             return qualid;
3139         }
3140 
3141         @Override @DefinedBy(Api.COMPILER_TREE)
3142         public List<JCExpression> getModuleNames() {
3143             return moduleNames;
3144         }
3145 
3146         @Override @DefinedBy(Api.COMPILER_TREE)
3147         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3148             return v.visitExports(this, d);
3149         }
3150 
3151         @Override
3152         public Tag getTag() {
3153             return Tag.EXPORTS;
3154         }
3155     }
3156 
3157     public static class JCOpens extends JCDirective
3158             implements OpensTree {
3159         public JCExpression qualid;
3160         public List<JCExpression> moduleNames;
3161         public OpensDirective directive;
3162 
3163         protected JCOpens(JCExpression qualId, List<JCExpression> moduleNames) {
3164             this.qualid = qualId;
3165             this.moduleNames = moduleNames;
3166         }
3167 
3168         @Override
3169         public void accept(Visitor v) { v.visitOpens(this); }
3170 
3171         @Override @DefinedBy(Api.COMPILER_TREE)
3172         public Kind getKind() {
3173             return Kind.OPENS;
3174         }
3175 
3176         @Override @DefinedBy(Api.COMPILER_TREE)
3177         public JCExpression getPackageName() {
3178             return qualid;
3179         }
3180 
3181         @Override @DefinedBy(Api.COMPILER_TREE)
3182         public List<JCExpression> getModuleNames() {
3183             return moduleNames;
3184         }
3185 
3186         @Override @DefinedBy(Api.COMPILER_TREE)
3187         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3188             return v.visitOpens(this, d);
3189         }
3190 
3191         @Override
3192         public Tag getTag() {
3193             return Tag.OPENS;
3194         }
3195     }
3196 
3197     public static class JCProvides extends JCDirective
3198             implements ProvidesTree {
3199         public JCExpression serviceName;
3200         public List<JCExpression> implNames;
3201 
3202         protected JCProvides(JCExpression serviceName, List<JCExpression> implNames) {
3203             this.serviceName = serviceName;
3204             this.implNames = implNames;
3205         }
3206 
3207         @Override
3208         public void accept(Visitor v) { v.visitProvides(this); }
3209 
3210         @Override @DefinedBy(Api.COMPILER_TREE)
3211         public Kind getKind() {
3212             return Kind.PROVIDES;
3213         }
3214 
3215         @Override @DefinedBy(Api.COMPILER_TREE)
3216         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3217             return v.visitProvides(this, d);
3218         }
3219 
3220         @Override @DefinedBy(Api.COMPILER_TREE)
3221         public JCExpression getServiceName() {
3222             return serviceName;
3223         }
3224 
3225         @Override @DefinedBy(Api.COMPILER_TREE)
3226         public List<JCExpression> getImplementationNames() {
3227             return implNames;
3228         }
3229 
3230         @Override
3231         public Tag getTag() {
3232             return PROVIDES;
3233         }
3234     }
3235 
3236     public static class JCRequires extends JCDirective
3237             implements RequiresTree {
3238         public boolean isTransitive;
3239         public boolean isStaticPhase;
3240         public JCExpression moduleName;
3241         public RequiresDirective directive;
3242 
3243         protected JCRequires(boolean isTransitive, boolean isStaticPhase, JCExpression moduleName) {
3244             this.isTransitive = isTransitive;
3245             this.isStaticPhase = isStaticPhase;
3246             this.moduleName = moduleName;
3247         }
3248 
3249         @Override
3250         public void accept(Visitor v) { v.visitRequires(this); }
3251 
3252         @Override @DefinedBy(Api.COMPILER_TREE)
3253         public Kind getKind() {
3254             return Kind.REQUIRES;
3255         }
3256 
3257         @Override @DefinedBy(Api.COMPILER_TREE)
3258         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3259             return v.visitRequires(this, d);
3260         }
3261 
3262         @Override @DefinedBy(Api.COMPILER_TREE)
3263         public boolean isTransitive() {
3264             return isTransitive;
3265         }
3266 
3267         @Override @DefinedBy(Api.COMPILER_TREE)
3268         public boolean isStatic() {
3269             return isStaticPhase;
3270         }
3271 
3272         @Override @DefinedBy(Api.COMPILER_TREE)
3273         public JCExpression getModuleName() {
3274             return moduleName;
3275         }
3276 
3277         @Override
3278         public Tag getTag() {
3279             return REQUIRES;
3280         }
3281     }
3282 
3283     public static class JCUses extends JCDirective
3284             implements UsesTree {
3285         public JCExpression qualid;
3286 
3287         protected JCUses(JCExpression qualId) {
3288             this.qualid = qualId;
3289         }
3290 
3291         @Override
3292         public void accept(Visitor v) { v.visitUses(this); }
3293 
3294         @Override @DefinedBy(Api.COMPILER_TREE)
3295         public Kind getKind() {
3296             return Kind.USES;
3297         }
3298 
3299         @Override @DefinedBy(Api.COMPILER_TREE)
3300         public JCExpression getServiceName() {
3301             return qualid;
3302         }
3303 
3304         @Override @DefinedBy(Api.COMPILER_TREE)
3305         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3306             return v.visitUses(this, d);
3307         }
3308 
3309         @Override
3310         public Tag getTag() {
3311             return USES;
3312         }
3313     }
3314 
3315     public static class JCErroneous extends JCExpression
3316             implements ErroneousTree {
3317         public List<? extends JCTree> errs;
3318         protected JCErroneous(List<? extends JCTree> errs) {
3319             this.errs = errs;
3320         }
3321         @Override
3322         public void accept(Visitor v) { v.visitErroneous(this); }
3323 
3324         @DefinedBy(Api.COMPILER_TREE)
3325         public Kind getKind() { return Kind.ERRONEOUS; }
3326 
3327         @DefinedBy(Api.COMPILER_TREE)
3328         public List<? extends JCTree> getErrorTrees() {
3329             return errs;
3330         }
3331 
3332         @Override @DefinedBy(Api.COMPILER_TREE)
3333         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3334             return v.visitErroneous(this, d);
3335         }
3336         @Override
3337         public Tag getTag() {
3338             return ERRONEOUS;
3339         }
3340     }
3341 
3342     /** (let int x = 3; in x+2) */
3343     public static class LetExpr extends JCExpression {
3344         public List<JCStatement> defs;
3345         public JCExpression expr;
3346         /**true if a expr should be run through Gen.genCond:*/
3347         public boolean needsCond;
3348         protected LetExpr(List<JCStatement> defs, JCExpression expr) {
3349             this.defs = defs;
3350             this.expr = expr;
3351         }
3352         @Override
3353         public void accept(Visitor v) { v.visitLetExpr(this); }
3354 
3355         @DefinedBy(Api.COMPILER_TREE)
3356         public Kind getKind() {
3357             throw new AssertionError("LetExpr is not part of a public API");
3358         }
3359         @Override @DefinedBy(Api.COMPILER_TREE)
3360         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3361             throw new AssertionError("LetExpr is not part of a public API");
3362         }
3363         @Override
3364         public Tag getTag() {
3365             return LETEXPR;
3366         }
3367     }
3368 
3369     /** An interface for tree factories
3370      */
3371     public interface Factory {
3372         JCCompilationUnit TopLevel(List<JCTree> defs);
3373         JCPackageDecl PackageDecl(List<JCAnnotation> annotations,
3374                                   JCExpression pid);
3375         JCImport Import(JCTree qualid, boolean staticImport);
3376         JCClassDecl ClassDef(JCModifiers mods,
3377                           Name name,
3378                           List<JCTypeParameter> typarams,
3379                           JCExpression extending,
3380                           List<JCExpression> implementing,
3381                           List<JCTree> defs);
3382         JCMethodDecl MethodDef(JCModifiers mods,
3383                             Name name,
3384                             JCExpression restype,
3385                             List<JCTypeParameter> typarams,
3386                             JCVariableDecl recvparam,
3387                             List<JCVariableDecl> params,
3388                             List<JCExpression> thrown,
3389                             JCBlock body,
3390                             JCExpression defaultValue);
3391         JCVariableDecl VarDef(JCModifiers mods,
3392                       Name name,
3393                       JCExpression vartype,
3394                       JCExpression init);
3395         JCSkip Skip();
3396         JCBlock Block(long flags, List<JCStatement> stats);
3397         JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
3398         JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
3399         JCForLoop ForLoop(List<JCStatement> init,
3400                         JCExpression cond,
3401                         List<JCExpressionStatement> step,
3402                         JCStatement body);
3403         JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
3404         JCLabeledStatement Labelled(Name label, JCStatement body);
3405         JCSwitch Switch(JCExpression selector, List<JCCase> cases);
3406         JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
3407         JCCase Case(CaseTree.CaseKind caseKind, List<JCCaseLabel> labels,
3408                     List<JCStatement> stats, JCTree body);
3409         JCDefaultValue DefaultValue(JCExpression type);
3410         JCSynchronized Synchronized(JCExpression lock, JCBlock body);
3411         JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
3412         JCTry Try(List<JCTree> resources,
3413                   JCBlock body,
3414                   List<JCCatch> catchers,
3415                   JCBlock finalizer);
3416         JCCatch Catch(JCVariableDecl param, JCBlock body);
3417         JCConditional Conditional(JCExpression cond,
3418                                 JCExpression thenpart,
3419                                 JCExpression elsepart);
3420         JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
3421         JCExpressionStatement Exec(JCExpression expr);
3422         JCBreak Break(Name label);
3423         JCYield Yield(JCExpression value);
3424         JCContinue Continue(Name label);
3425         JCReturn Return(JCExpression expr);
3426         JCThrow Throw(JCExpression expr);
3427         JCAssert Assert(JCExpression cond, JCExpression detail);
3428         JCMethodInvocation Apply(List<JCExpression> typeargs,
3429                     JCExpression fn,
3430                     List<JCExpression> args);
3431         JCNewClass NewClass(JCExpression encl,
3432                           List<JCExpression> typeargs,
3433                           JCExpression clazz,
3434                           List<JCExpression> args,
3435                           JCClassDecl def);
3436         JCNewArray NewArray(JCExpression elemtype,
3437                           List<JCExpression> dims,
3438                           List<JCExpression> elems);
3439         JCParens Parens(JCExpression expr);
3440         JCAssign Assign(JCExpression lhs, JCExpression rhs);
3441         JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
3442         JCUnary Unary(Tag opcode, JCExpression arg);
3443         JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
3444         JCTypeCast TypeCast(JCTree expr, JCExpression type);
3445         JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
3446         JCBindingPattern BindingPattern(JCVariableDecl var);
3447         JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
3448         JCFieldAccess Select(JCExpression selected, Name selector);
3449         JCIdent Ident(Name idname);
3450         JCLiteral Literal(TypeTag tag, Object value);
3451         JCPrimitiveTypeTree TypeIdent(TypeTag typetag);
3452         JCArrayTypeTree TypeArray(JCExpression elemtype);
3453         JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
3454         JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
3455         JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
3456         TypeBoundKind TypeBoundKind(BoundKind kind);
3457         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
3458         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
3459         JCErroneous Erroneous(List<? extends JCTree> errs);
3460         JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind, JCExpression qualId, List<JCDirective> directives);
3461         JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames);
3462         JCOpens Opens(JCExpression qualId, List<JCExpression> moduleNames);
3463         JCProvides Provides(JCExpression serviceName, List<JCExpression> implNames);
3464         JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId);
3465         JCUses Uses(JCExpression qualId);
3466         LetExpr LetExpr(List<JCStatement> defs, JCExpression expr);
3467     }
3468 
3469     /** A generic visitor class for trees.
3470      */
3471     public static abstract class Visitor {
3472         public void visitTopLevel(JCCompilationUnit that)    { visitTree(that); }
3473         public void visitPackageDef(JCPackageDecl that)      { visitTree(that); }
3474         public void visitImport(JCImport that)               { visitTree(that); }
3475         public void visitClassDef(JCClassDecl that)          { visitTree(that); }
3476         public void visitMethodDef(JCMethodDecl that)        { visitTree(that); }
3477         public void visitVarDef(JCVariableDecl that)         { visitTree(that); }
3478         public void visitSkip(JCSkip that)                   { visitTree(that); }
3479         public void visitBlock(JCBlock that)                 { visitTree(that); }
3480         public void visitDoLoop(JCDoWhileLoop that)          { visitTree(that); }
3481         public void visitWhileLoop(JCWhileLoop that)         { visitTree(that); }
3482         public void visitWithField(JCWithField that)         { visitTree(that); }
3483         public void visitForLoop(JCForLoop that)             { visitTree(that); }
3484         public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
3485         public void visitLabelled(JCLabeledStatement that)   { visitTree(that); }
3486         public void visitSwitch(JCSwitch that)               { visitTree(that); }
3487         public void visitCase(JCCase that)                   { visitTree(that); }
3488         public void visitDefaultValue(JCDefaultValue that) { visitTree(that); }
3489         public void visitSwitchExpression(JCSwitchExpression that)               { visitTree(that); }
3490         public void visitSynchronized(JCSynchronized that)   { visitTree(that); }
3491         public void visitTry(JCTry that)                     { visitTree(that); }
3492         public void visitCatch(JCCatch that)                 { visitTree(that); }
3493         public void visitConditional(JCConditional that)     { visitTree(that); }
3494         public void visitIf(JCIf that)                       { visitTree(that); }
3495         public void visitExec(JCExpressionStatement that)    { visitTree(that); }
3496         public void visitBreak(JCBreak that)                 { visitTree(that); }
3497         public void visitYield(JCYield that)                 { visitTree(that); }
3498         public void visitContinue(JCContinue that)           { visitTree(that); }
3499         public void visitReturn(JCReturn that)               { visitTree(that); }
3500         public void visitThrow(JCThrow that)                 { visitTree(that); }
3501         public void visitAssert(JCAssert that)               { visitTree(that); }
3502         public void visitApply(JCMethodInvocation that)      { visitTree(that); }
3503         public void visitNewClass(JCNewClass that)           { visitTree(that); }
3504         public void visitNewArray(JCNewArray that)           { visitTree(that); }
3505         public void visitLambda(JCLambda that)               { visitTree(that); }
3506         public void visitParens(JCParens that)               { visitTree(that); }
3507         public void visitAssign(JCAssign that)               { visitTree(that); }
3508         public void visitAssignop(JCAssignOp that)           { visitTree(that); }
3509         public void visitUnary(JCUnary that)                 { visitTree(that); }
3510         public void visitBinary(JCBinary that)               { visitTree(that); }
3511         public void visitTypeCast(JCTypeCast that)           { visitTree(that); }
3512         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
3513         public void visitBindingPattern(JCBindingPattern that) { visitTree(that); }
3514         public void visitDefaultCaseLabel(JCDefaultCaseLabel that) { visitTree(that); }
3515         public void visitParenthesizedPattern(JCParenthesizedPattern that) { visitTree(that); }
3516         public void visitGuardPattern(JCGuardPattern that) { visitTree(that); }
3517         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
3518         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
3519         public void visitReference(JCMemberReference that)   { visitTree(that); }
3520         public void visitIdent(JCIdent that)                 { visitTree(that); }
3521         public void visitLiteral(JCLiteral that)             { visitTree(that); }
3522         public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
3523         public void visitTypeArray(JCArrayTypeTree that)     { visitTree(that); }
3524         public void visitTypeApply(JCTypeApply that)         { visitTree(that); }
3525         public void visitTypeUnion(JCTypeUnion that)         { visitTree(that); }
3526         public void visitTypeIntersection(JCTypeIntersection that)  { visitTree(that); }
3527         public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
3528         public void visitWildcard(JCWildcard that)           { visitTree(that); }
3529         public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
3530         public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
3531         public void visitModifiers(JCModifiers that)         { visitTree(that); }
3532         public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
3533         public void visitErroneous(JCErroneous that)         { visitTree(that); }
3534         public void visitModuleDef(JCModuleDecl that)        { visitTree(that); }
3535         public void visitExports(JCExports that)             { visitTree(that); }
3536         public void visitOpens(JCOpens that)                 { visitTree(that); }
3537         public void visitProvides(JCProvides that)           { visitTree(that); }
3538         public void visitRequires(JCRequires that)           { visitTree(that); }
3539         public void visitUses(JCUses that)                   { visitTree(that); }
3540         public void visitLetExpr(LetExpr that)               { visitTree(that); }
3541 
3542         public void visitTree(JCTree that)                   { Assert.error(); }
3543     }
3544 
3545 }