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 abstract static 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 abstract static 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 abstract static 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 abstract static 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 abstract static 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 isExhaustive;
1329         public boolean patternSwitch;
1330         protected JCSwitch(JCExpression selector, List<JCCase> cases) {
1331             this.selector = selector;
1332             this.cases = cases;
1333         }
1334         @Override
1335         public void accept(Visitor v) { v.visitSwitch(this); }
1336 
1337         @DefinedBy(Api.COMPILER_TREE)
1338         public Kind getKind() { return Kind.SWITCH; }
1339         @DefinedBy(Api.COMPILER_TREE)
1340         public JCExpression getExpression() { return selector; }
1341         @DefinedBy(Api.COMPILER_TREE)
1342         public List<JCCase> getCases() { return cases; }
1343         @Override @DefinedBy(Api.COMPILER_TREE)
1344         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1345             return v.visitSwitch(this, d);
1346         }
1347         @Override
1348         public Tag getTag() {
1349             return SWITCH;
1350         }
1351     }
1352 
1353     /**
1354      * A "case  :" of a switch.
1355      */
1356     public static class JCCase extends JCStatement implements CaseTree {
1357         //as CaseKind is deprecated for removal (as it is part of a preview feature),
1358         //using indirection through these fields to avoid unnecessary @SuppressWarnings:
1359         public static final CaseKind STATEMENT = CaseKind.STATEMENT;
1360         public static final CaseKind RULE = CaseKind.RULE;
1361         public final CaseKind caseKind;
1362         public List<JCCaseLabel> labels;
1363         public List<JCStatement> stats;
1364         public JCTree body;
1365         public boolean completesNormally;
1366         protected JCCase(CaseKind caseKind, List<JCCaseLabel> labels,
1367                          List<JCStatement> stats, JCTree body) {
1368             Assert.checkNonNull(labels);
1369             Assert.check(labels.isEmpty() || labels.head != null);
1370             this.caseKind = caseKind;
1371             this.labels = labels;
1372             this.stats = stats;
1373             this.body = body;
1374         }
1375         @Override
1376         public void accept(Visitor v) { v.visitCase(this); }
1377 
1378         @Override @DefinedBy(Api.COMPILER_TREE)
1379         public Kind getKind() { return Kind.CASE; }
1380         @Override @Deprecated @DefinedBy(Api.COMPILER_TREE)
1381         public JCExpression getExpression() { return getExpressions().head; }
1382         @Override @DefinedBy(Api.COMPILER_TREE)
1383         public List<JCExpression> getExpressions() { return labels.stream().filter(p -> p instanceof JCExpression).map(p -> (JCExpression) p).collect(List.collector()); }
1384         @Override @DefinedBy(Api.COMPILER_TREE)
1385         public List<JCCaseLabel> getLabels() { return labels; }
1386         @Override @DefinedBy(Api.COMPILER_TREE)
1387         public List<JCStatement> getStatements() {
1388             return caseKind == CaseKind.STATEMENT ? stats : null;
1389         }
1390         @Override @DefinedBy(Api.COMPILER_TREE)
1391         public JCTree getBody() { return body; }
1392         @Override @DefinedBy(Api.COMPILER_TREE)
1393         public CaseKind getCaseKind() {
1394             return caseKind;
1395         }
1396         @Override @DefinedBy(Api.COMPILER_TREE)
1397         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1398             return v.visitCase(this, d);
1399         }
1400         @Override
1401         public Tag getTag() {
1402             return CASE;
1403         }
1404     }
1405 
1406     /**
1407      * A "Identifier<TA1, TA2>.default" construction.
1408      */
1409     public static class JCDefaultValue extends JCPolyExpression implements DefaultValueTree {
1410         public JCExpression clazz;
1411 
1412         protected JCDefaultValue(JCExpression clazz) {
1413             this.clazz = clazz;
1414         }
1415         @Override
1416         public void accept(Visitor v) { v.visitDefaultValue(this); }
1417 
1418         @DefinedBy(Api.COMPILER_TREE)
1419         public Kind getKind() { return Kind.DEFAULT_VALUE; }
1420         @Override @DefinedBy(Api.COMPILER_TREE)
1421         public JCExpression getType() { return clazz; }
1422         @Override @DefinedBy(Api.COMPILER_TREE)
1423         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1424             return v.visitDefaultValue(this, d);
1425         }
1426         @Override
1427         public Tag getTag() {
1428             return DEFAULT_VALUE;
1429         }
1430     }
1431 
1432     /**
1433      * A "switch ( ) { }" construction.
1434      */
1435     public static class JCSwitchExpression extends JCPolyExpression implements SwitchExpressionTree {
1436         public JCExpression selector;
1437         public List<JCCase> cases;
1438         /** Position of closing brace, optional. */
1439         public int endpos = Position.NOPOS;
1440         public boolean hasTotalPattern;
1441         public boolean isExhaustive;
1442         public boolean patternSwitch;
1443         protected JCSwitchExpression(JCExpression selector, List<JCCase> cases) {
1444             this.selector = selector;
1445             this.cases = cases;
1446         }
1447         @Override
1448         public void accept(Visitor v) { v.visitSwitchExpression(this); }
1449 
1450         @DefinedBy(Api.COMPILER_TREE)
1451         public Kind getKind() { return Kind.SWITCH_EXPRESSION; }
1452         @DefinedBy(Api.COMPILER_TREE)
1453         public JCExpression getExpression() { return selector; }
1454         @DefinedBy(Api.COMPILER_TREE)
1455         public List<JCCase> getCases() { return cases; }
1456         @Override @DefinedBy(Api.COMPILER_TREE)
1457         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1458             return v.visitSwitchExpression(this, d);
1459         }
1460         @Override
1461         public Tag getTag() {
1462             return SWITCH_EXPRESSION;
1463         }
1464     }
1465 
1466     /**
1467      * A synchronized block.
1468      */
1469     public static class JCSynchronized extends JCStatement implements SynchronizedTree {
1470         public JCExpression lock;
1471         public JCBlock body;
1472         protected JCSynchronized(JCExpression lock, JCBlock body) {
1473             this.lock = lock;
1474             this.body = body;
1475         }
1476         @Override
1477         public void accept(Visitor v) { v.visitSynchronized(this); }
1478 
1479         @DefinedBy(Api.COMPILER_TREE)
1480         public Kind getKind() { return Kind.SYNCHRONIZED; }
1481         @DefinedBy(Api.COMPILER_TREE)
1482         public JCExpression getExpression() { return lock; }
1483         @DefinedBy(Api.COMPILER_TREE)
1484         public JCBlock getBlock() { return body; }
1485         @Override @DefinedBy(Api.COMPILER_TREE)
1486         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1487             return v.visitSynchronized(this, d);
1488         }
1489         @Override
1490         public Tag getTag() {
1491             return SYNCHRONIZED;
1492         }
1493     }
1494 
1495     /**
1496      * A "try { } catch ( ) { } finally { }" block.
1497      */
1498     public static class JCTry extends JCStatement implements TryTree {
1499         public JCBlock body;
1500         public List<JCCatch> catchers;
1501         public JCBlock finalizer;
1502         public List<JCTree> resources;
1503         public boolean finallyCanCompleteNormally;
1504         protected JCTry(List<JCTree> resources,
1505                         JCBlock body,
1506                         List<JCCatch> catchers,
1507                         JCBlock finalizer) {
1508             this.body = body;
1509             this.catchers = catchers;
1510             this.finalizer = finalizer;
1511             this.resources = resources;
1512         }
1513         @Override
1514         public void accept(Visitor v) { v.visitTry(this); }
1515 
1516         @DefinedBy(Api.COMPILER_TREE)
1517         public Kind getKind() { return Kind.TRY; }
1518         @DefinedBy(Api.COMPILER_TREE)
1519         public JCBlock getBlock() { return body; }
1520         @DefinedBy(Api.COMPILER_TREE)
1521         public List<JCCatch> getCatches() {
1522             return catchers;
1523         }
1524         @DefinedBy(Api.COMPILER_TREE)
1525         public JCBlock getFinallyBlock() { return finalizer; }
1526         @Override @DefinedBy(Api.COMPILER_TREE)
1527         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1528             return v.visitTry(this, d);
1529         }
1530         @Override @DefinedBy(Api.COMPILER_TREE)
1531         public List<JCTree> getResources() {
1532             return resources;
1533         }
1534         @Override
1535         public Tag getTag() {
1536             return TRY;
1537         }
1538     }
1539 
1540     /**
1541      * A catch block.
1542      */
1543     public static class JCCatch extends JCTree implements CatchTree {
1544         public JCVariableDecl param;
1545         public JCBlock body;
1546         protected JCCatch(JCVariableDecl param, JCBlock body) {
1547             this.param = param;
1548             this.body = body;
1549         }
1550         @Override
1551         public void accept(Visitor v) { v.visitCatch(this); }
1552 
1553         @DefinedBy(Api.COMPILER_TREE)
1554         public Kind getKind() { return Kind.CATCH; }
1555         @DefinedBy(Api.COMPILER_TREE)
1556         public JCVariableDecl getParameter() { return param; }
1557         @DefinedBy(Api.COMPILER_TREE)
1558         public JCBlock getBlock() { return body; }
1559         @Override @DefinedBy(Api.COMPILER_TREE)
1560         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1561             return v.visitCatch(this, d);
1562         }
1563         @Override
1564         public Tag getTag() {
1565             return CATCH;
1566         }
1567     }
1568 
1569     /**
1570      * A ( ) ? ( ) : ( ) conditional expression
1571      */
1572     public static class JCConditional extends JCPolyExpression implements ConditionalExpressionTree {
1573         public JCExpression cond;
1574         public JCExpression truepart;
1575         public JCExpression falsepart;
1576         protected JCConditional(JCExpression cond,
1577                               JCExpression truepart,
1578                               JCExpression falsepart)
1579         {
1580             this.cond = cond;
1581             this.truepart = truepart;
1582             this.falsepart = falsepart;
1583         }
1584         @Override
1585         public void accept(Visitor v) { v.visitConditional(this); }
1586 
1587         @DefinedBy(Api.COMPILER_TREE)
1588         public Kind getKind() { return Kind.CONDITIONAL_EXPRESSION; }
1589         @DefinedBy(Api.COMPILER_TREE)
1590         public JCExpression getCondition() { return cond; }
1591         @DefinedBy(Api.COMPILER_TREE)
1592         public JCExpression getTrueExpression() { return truepart; }
1593         @DefinedBy(Api.COMPILER_TREE)
1594         public JCExpression getFalseExpression() { return falsepart; }
1595         @Override @DefinedBy(Api.COMPILER_TREE)
1596         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1597             return v.visitConditionalExpression(this, d);
1598         }
1599         @Override
1600         public Tag getTag() {
1601             return CONDEXPR;
1602         }
1603     }
1604 
1605     /**
1606      * An "if ( ) { } else { }" block
1607      */
1608     public static class JCIf extends JCStatement implements IfTree {
1609         public JCExpression cond;
1610         public JCStatement thenpart;
1611         public JCStatement elsepart;
1612         protected JCIf(JCExpression cond,
1613                      JCStatement thenpart,
1614                      JCStatement elsepart)
1615         {
1616             this.cond = cond;
1617             this.thenpart = thenpart;
1618             this.elsepart = elsepart;
1619         }
1620         @Override
1621         public void accept(Visitor v) { v.visitIf(this); }
1622 
1623         @DefinedBy(Api.COMPILER_TREE)
1624         public Kind getKind() { return Kind.IF; }
1625         @DefinedBy(Api.COMPILER_TREE)
1626         public JCExpression getCondition() { return cond; }
1627         @DefinedBy(Api.COMPILER_TREE)
1628         public JCStatement getThenStatement() { return thenpart; }
1629         @DefinedBy(Api.COMPILER_TREE)
1630         public JCStatement getElseStatement() { return elsepart; }
1631         @Override @DefinedBy(Api.COMPILER_TREE)
1632         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1633             return v.visitIf(this, d);
1634         }
1635         @Override
1636         public Tag getTag() {
1637             return IF;
1638         }
1639     }
1640 
1641     /**
1642      * an expression statement
1643      */
1644     public static class JCExpressionStatement extends JCStatement implements ExpressionStatementTree {
1645         /** expression structure */
1646         public JCExpression expr;
1647         protected JCExpressionStatement(JCExpression expr)
1648         {
1649             this.expr = expr;
1650         }
1651         @Override
1652         public void accept(Visitor v) { v.visitExec(this); }
1653 
1654         @DefinedBy(Api.COMPILER_TREE)
1655         public Kind getKind() { return Kind.EXPRESSION_STATEMENT; }
1656         @DefinedBy(Api.COMPILER_TREE)
1657         public JCExpression getExpression() { return expr; }
1658         @Override @DefinedBy(Api.COMPILER_TREE)
1659         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1660             return v.visitExpressionStatement(this, d);
1661         }
1662         @Override
1663         public Tag getTag() {
1664             return EXEC;
1665         }
1666 
1667         /** Convert a expression-statement tree to a pretty-printed string. */
1668         @Override
1669         public String toString() {
1670             StringWriter s = new StringWriter();
1671             try {
1672                 new Pretty(s, false).printStat(this);
1673             }
1674             catch (IOException e) {
1675                 // should never happen, because StringWriter is defined
1676                 // never to throw any IOExceptions
1677                 throw new AssertionError(e);
1678             }
1679             return s.toString();
1680         }
1681     }
1682 
1683     /**
1684      * A break from a loop or switch.
1685      */
1686     public static class JCBreak extends JCStatement implements BreakTree {
1687         public Name label;
1688         public JCTree target;
1689         protected JCBreak(Name label, JCTree target) {
1690             this.label = label;
1691             this.target = target;
1692         }
1693         @Override
1694         public void accept(Visitor v) { v.visitBreak(this); }
1695         public boolean isValueBreak() {
1696             return target != null && target.hasTag(SWITCH_EXPRESSION);
1697         }
1698 
1699         @DefinedBy(Api.COMPILER_TREE)
1700         public Kind getKind() { return Kind.BREAK; }
1701         @DefinedBy(Api.COMPILER_TREE)
1702         public Name getLabel() {
1703             return label;
1704         }
1705         @Override @DefinedBy(Api.COMPILER_TREE)
1706         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1707             return v.visitBreak(this, d);
1708         }
1709         @Override
1710         public Tag getTag() {
1711             return BREAK;
1712         }
1713     }
1714 
1715     /**
1716      * A break-with from a switch expression.
1717      */
1718     public static class JCYield extends JCStatement implements YieldTree {
1719         public JCExpression value;
1720         public JCTree target;
1721         protected JCYield(JCExpression value, JCTree target) {
1722             this.value = value;
1723             this.target = target;
1724         }
1725         @Override
1726         public void accept(Visitor v) { v.visitYield(this); }
1727         @DefinedBy(Api.COMPILER_TREE)
1728         public Kind getKind() { return Kind.YIELD; }
1729         @DefinedBy(Api.COMPILER_TREE)
1730         public JCExpression getValue() { return value; }
1731         @Override @DefinedBy(Api.COMPILER_TREE)
1732         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1733             return v.visitYield(this, d);
1734         }
1735         @Override
1736         public Tag getTag() {
1737             return YIELD;
1738         }
1739     }
1740 
1741     /**
1742      * A continue of a loop.
1743      */
1744     public static class JCContinue extends JCStatement implements ContinueTree {
1745         public Name label;
1746         public JCTree target;
1747         protected JCContinue(Name label, JCTree target) {
1748             this.label = label;
1749             this.target = target;
1750         }
1751         @Override
1752         public void accept(Visitor v) { v.visitContinue(this); }
1753 
1754         @DefinedBy(Api.COMPILER_TREE)
1755         public Kind getKind() { return Kind.CONTINUE; }
1756         @DefinedBy(Api.COMPILER_TREE)
1757         public Name getLabel() { return label; }
1758         @Override @DefinedBy(Api.COMPILER_TREE)
1759         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1760             return v.visitContinue(this, d);
1761         }
1762         @Override
1763         public Tag getTag() {
1764             return CONTINUE;
1765         }
1766     }
1767 
1768     /**
1769      * A return statement.
1770      */
1771     public static class JCReturn extends JCStatement implements ReturnTree {
1772         public JCExpression expr;
1773         protected JCReturn(JCExpression expr) {
1774             this.expr = expr;
1775         }
1776         @Override
1777         public void accept(Visitor v) { v.visitReturn(this); }
1778 
1779         @DefinedBy(Api.COMPILER_TREE)
1780         public Kind getKind() { return Kind.RETURN; }
1781         @DefinedBy(Api.COMPILER_TREE)
1782         public JCExpression getExpression() { return expr; }
1783         @Override @DefinedBy(Api.COMPILER_TREE)
1784         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1785             return v.visitReturn(this, d);
1786         }
1787         @Override
1788         public Tag getTag() {
1789             return RETURN;
1790         }
1791     }
1792 
1793     /**
1794      * A throw statement.
1795      */
1796     public static class JCThrow extends JCStatement implements ThrowTree {
1797         public JCExpression expr;
1798         protected JCThrow(JCExpression expr) {
1799             this.expr = expr;
1800         }
1801         @Override
1802         public void accept(Visitor v) { v.visitThrow(this); }
1803 
1804         @DefinedBy(Api.COMPILER_TREE)
1805         public Kind getKind() { return Kind.THROW; }
1806         @DefinedBy(Api.COMPILER_TREE)
1807         public JCExpression getExpression() { return expr; }
1808         @Override @DefinedBy(Api.COMPILER_TREE)
1809         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1810             return v.visitThrow(this, d);
1811         }
1812         @Override
1813         public Tag getTag() {
1814             return THROW;
1815         }
1816     }
1817 
1818     /**
1819      * An assert statement.
1820      */
1821     public static class JCAssert extends JCStatement implements AssertTree {
1822         public JCExpression cond;
1823         public JCExpression detail;
1824         protected JCAssert(JCExpression cond, JCExpression detail) {
1825             this.cond = cond;
1826             this.detail = detail;
1827         }
1828         @Override
1829         public void accept(Visitor v) { v.visitAssert(this); }
1830 
1831         @DefinedBy(Api.COMPILER_TREE)
1832         public Kind getKind() { return Kind.ASSERT; }
1833         @DefinedBy(Api.COMPILER_TREE)
1834         public JCExpression getCondition() { return cond; }
1835         @DefinedBy(Api.COMPILER_TREE)
1836         public JCExpression getDetail() { return detail; }
1837         @Override @DefinedBy(Api.COMPILER_TREE)
1838         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1839             return v.visitAssert(this, d);
1840         }
1841         @Override
1842         public Tag getTag() {
1843             return ASSERT;
1844         }
1845     }
1846 
1847     /**
1848      * A method invocation
1849      */
1850     public static class JCMethodInvocation extends JCPolyExpression implements MethodInvocationTree {
1851         public List<JCExpression> typeargs;
1852         public JCExpression meth;
1853         public List<JCExpression> args;
1854         public Type varargsElement;
1855         protected JCMethodInvocation(List<JCExpression> typeargs,
1856                         JCExpression meth,
1857                         List<JCExpression> args)
1858         {
1859             this.typeargs = (typeargs == null) ? List.nil()
1860                                                : typeargs;
1861             this.meth = meth;
1862             this.args = args;
1863         }
1864         @Override
1865         public void accept(Visitor v) { v.visitApply(this); }
1866 
1867         @DefinedBy(Api.COMPILER_TREE)
1868         public Kind getKind() { return Kind.METHOD_INVOCATION; }
1869         @DefinedBy(Api.COMPILER_TREE)
1870         public List<JCExpression> getTypeArguments() {
1871             return typeargs;
1872         }
1873         @DefinedBy(Api.COMPILER_TREE)
1874         public JCExpression getMethodSelect() { return meth; }
1875         @DefinedBy(Api.COMPILER_TREE)
1876         public List<JCExpression> getArguments() {
1877             return args;
1878         }
1879         @Override @DefinedBy(Api.COMPILER_TREE)
1880         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1881             return v.visitMethodInvocation(this, d);
1882         }
1883         @Override
1884         public JCMethodInvocation setType(Type type) {
1885             super.setType(type);
1886             return this;
1887         }
1888         @Override
1889         public Tag getTag() {
1890             return(APPLY);
1891         }
1892     }
1893 
1894     /**
1895      * A new(...) operation.
1896      */
1897     public static class JCNewClass extends JCPolyExpression implements NewClassTree {
1898         public JCExpression encl;
1899         public List<JCExpression> typeargs;
1900         public JCExpression clazz;
1901         public List<JCExpression> args;
1902         public JCClassDecl def;
1903         public Symbol constructor;
1904         public Type varargsElement;
1905         public Type constructorType;
1906         protected JCNewClass(JCExpression encl,
1907                            List<JCExpression> typeargs,
1908                            JCExpression clazz,
1909                            List<JCExpression> args,
1910                            JCClassDecl def)
1911         {
1912             this.encl = encl;
1913             this.typeargs = (typeargs == null) ? List.nil()
1914                                                : typeargs;
1915             this.clazz = clazz;
1916             this.args = args;
1917             this.def = def;
1918         }
1919         @Override
1920         public void accept(Visitor v) { v.visitNewClass(this); }
1921 
1922         @DefinedBy(Api.COMPILER_TREE)
1923         public Kind getKind() { return Kind.NEW_CLASS; }
1924         @DefinedBy(Api.COMPILER_TREE)
1925         public JCExpression getEnclosingExpression() { // expr.new C< ... > ( ... )
1926             return encl;
1927         }
1928         @DefinedBy(Api.COMPILER_TREE)
1929         public List<JCExpression> getTypeArguments() {
1930             return typeargs;
1931         }
1932         @DefinedBy(Api.COMPILER_TREE)
1933         public JCExpression getIdentifier() { return clazz; }
1934         @DefinedBy(Api.COMPILER_TREE)
1935         public List<JCExpression> getArguments() {
1936             return args;
1937         }
1938         @DefinedBy(Api.COMPILER_TREE)
1939         public JCClassDecl getClassBody() { return def; }
1940         @Override @DefinedBy(Api.COMPILER_TREE)
1941         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1942             return v.visitNewClass(this, d);
1943         }
1944         @Override
1945         public Tag getTag() {
1946             return NEWCLASS;
1947         }
1948 
1949         public boolean classDeclRemoved() {
1950             return false;
1951         }
1952     }
1953 
1954     /**
1955      * A new[...] operation.
1956      */
1957     public static class JCNewArray extends JCExpression implements NewArrayTree {
1958         public JCExpression elemtype;
1959         public List<JCExpression> dims;
1960         // type annotations on inner-most component
1961         public List<JCAnnotation> annotations;
1962         // type annotations on dimensions
1963         public List<List<JCAnnotation>> dimAnnotations;
1964         public List<JCExpression> elems;
1965         protected JCNewArray(JCExpression elemtype,
1966                            List<JCExpression> dims,
1967                            List<JCExpression> elems)
1968         {
1969             this.elemtype = elemtype;
1970             this.dims = dims;
1971             this.annotations = List.nil();
1972             this.dimAnnotations = List.nil();
1973             this.elems = elems;
1974         }
1975         @Override
1976         public void accept(Visitor v) { v.visitNewArray(this); }
1977 
1978         @DefinedBy(Api.COMPILER_TREE)
1979         public Kind getKind() { return Kind.NEW_ARRAY; }
1980         @DefinedBy(Api.COMPILER_TREE)
1981         public JCExpression getType() { return elemtype; }
1982         @DefinedBy(Api.COMPILER_TREE)
1983         public List<JCExpression> getDimensions() {
1984             return dims;
1985         }
1986         @DefinedBy(Api.COMPILER_TREE)
1987         public List<JCExpression> getInitializers() {
1988             return elems;
1989         }
1990         @Override @DefinedBy(Api.COMPILER_TREE)
1991         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
1992             return v.visitNewArray(this, d);
1993         }
1994         @Override
1995         public Tag getTag() {
1996             return NEWARRAY;
1997         }
1998 
1999         @Override @DefinedBy(Api.COMPILER_TREE)
2000         public List<JCAnnotation> getAnnotations() {
2001             return annotations;
2002         }
2003 
2004         @Override @DefinedBy(Api.COMPILER_TREE)
2005         public List<List<JCAnnotation>> getDimAnnotations() {
2006             return dimAnnotations;
2007         }
2008     }
2009 
2010     /**
2011      * A lambda expression.
2012      */
2013     public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2014 
2015         public enum ParameterKind {
2016             IMPLICIT,
2017             EXPLICIT
2018         }
2019 
2020         public List<JCVariableDecl> params;
2021         public JCTree body;
2022         public boolean canCompleteNormally = true;
2023         public ParameterKind paramKind;
2024 
2025         public JCLambda(List<JCVariableDecl> params,
2026                         JCTree body) {
2027             this.params = params;
2028             this.body = body;
2029             if (params.isEmpty() ||
2030                 params.head.vartype != null) {
2031                 paramKind = ParameterKind.EXPLICIT;
2032             } else {
2033                 paramKind = ParameterKind.IMPLICIT;
2034             }
2035         }
2036         @Override
2037         public Tag getTag() {
2038             return LAMBDA;
2039         }
2040         @Override
2041         public void accept(Visitor v) {
2042             v.visitLambda(this);
2043         }
2044         @Override @DefinedBy(Api.COMPILER_TREE)
2045         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2046             return v.visitLambdaExpression(this, d);
2047         }
2048         @DefinedBy(Api.COMPILER_TREE)
2049         public Kind getKind() {
2050             return Kind.LAMBDA_EXPRESSION;
2051         }
2052         @DefinedBy(Api.COMPILER_TREE)
2053         public JCTree getBody() {
2054             return body;
2055         }
2056         @DefinedBy(Api.COMPILER_TREE)
2057         public java.util.List<? extends VariableTree> getParameters() {
2058             return params;
2059         }
2060         @Override
2061         public JCLambda setType(Type type) {
2062             super.setType(type);
2063             return this;
2064         }
2065         @Override @DefinedBy(Api.COMPILER_TREE)
2066         public BodyKind getBodyKind() {
2067             return body.hasTag(BLOCK) ?
2068                     BodyKind.STATEMENT :
2069                     BodyKind.EXPRESSION;
2070         }
2071     }
2072 
2073     /**
2074      * A parenthesized subexpression ( ... )
2075      */
2076     public static class JCParens extends JCExpression implements ParenthesizedTree {
2077         public JCExpression expr;
2078         protected JCParens(JCExpression expr) {
2079             this.expr = expr;
2080         }
2081         @Override
2082         public void accept(Visitor v) { v.visitParens(this); }
2083 
2084         @DefinedBy(Api.COMPILER_TREE)
2085         public Kind getKind() { return Kind.PARENTHESIZED; }
2086         @DefinedBy(Api.COMPILER_TREE)
2087         public JCExpression getExpression() { return expr; }
2088         @Override @DefinedBy(Api.COMPILER_TREE)
2089         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2090             return v.visitParenthesized(this, d);
2091         }
2092         @Override
2093         public Tag getTag() {
2094             return PARENS;
2095         }
2096     }
2097 
2098     /**
2099      * A assignment with "=".
2100      */
2101     public static class JCAssign extends JCExpression implements AssignmentTree {
2102         public JCExpression lhs;
2103         public JCExpression rhs;
2104         protected JCAssign(JCExpression lhs, JCExpression rhs) {
2105             this.lhs = lhs;
2106             this.rhs = rhs;
2107         }
2108         @Override
2109         public void accept(Visitor v) { v.visitAssign(this); }
2110 
2111         @DefinedBy(Api.COMPILER_TREE)
2112         public Kind getKind() { return Kind.ASSIGNMENT; }
2113         @DefinedBy(Api.COMPILER_TREE)
2114         public JCExpression getVariable() { return lhs; }
2115         @DefinedBy(Api.COMPILER_TREE)
2116         public JCExpression getExpression() { return rhs; }
2117         @Override @DefinedBy(Api.COMPILER_TREE)
2118         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2119             return v.visitAssignment(this, d);
2120         }
2121         @Override
2122         public Tag getTag() {
2123             return ASSIGN;
2124         }
2125     }
2126 
2127     public abstract static class JCOperatorExpression extends JCExpression {
2128         public enum OperandPos {
2129             LEFT,
2130             RIGHT
2131         }
2132 
2133         protected Tag opcode;
2134         public OperatorSymbol operator;
2135 
2136         public OperatorSymbol getOperator() {
2137             return operator;
2138         }
2139 
2140         @Override
2141         public Tag getTag() {
2142             return opcode;
2143         }
2144 
2145         public abstract JCExpression getOperand(OperandPos pos);
2146     }
2147 
2148     /**
2149      * An assignment with "+=", "|=" ...
2150      */
2151     public static class JCAssignOp extends JCOperatorExpression implements CompoundAssignmentTree {
2152         public JCExpression lhs;
2153         public JCExpression rhs;
2154         protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, OperatorSymbol operator) {
2155             this.opcode = opcode;
2156             this.lhs = (JCExpression)lhs;
2157             this.rhs = (JCExpression)rhs;
2158             this.operator = operator;
2159         }
2160         @Override
2161         public void accept(Visitor v) { v.visitAssignop(this); }
2162 
2163         @DefinedBy(Api.COMPILER_TREE)
2164         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2165         @DefinedBy(Api.COMPILER_TREE)
2166         public JCExpression getVariable() { return lhs; }
2167         @DefinedBy(Api.COMPILER_TREE)
2168         public JCExpression getExpression() { return rhs; }
2169         @Override @DefinedBy(Api.COMPILER_TREE)
2170         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2171             return v.visitCompoundAssignment(this, d);
2172         }
2173         @Override
2174         public JCExpression getOperand(OperandPos pos) {
2175             return pos == OperandPos.LEFT ? lhs : rhs;
2176         }
2177     }
2178 
2179     /**
2180      * A unary operation.
2181      */
2182     public static class JCUnary extends JCOperatorExpression implements UnaryTree {
2183         public JCExpression arg;
2184         protected JCUnary(Tag opcode, JCExpression arg) {
2185             this.opcode = opcode;
2186             this.arg = arg;
2187         }
2188         @Override
2189         public void accept(Visitor v) { v.visitUnary(this); }
2190 
2191         @DefinedBy(Api.COMPILER_TREE)
2192         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2193         @DefinedBy(Api.COMPILER_TREE)
2194         public JCExpression getExpression() { return arg; }
2195         @Override @DefinedBy(Api.COMPILER_TREE)
2196         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2197             return v.visitUnary(this, d);
2198         }
2199         public void setTag(Tag tag) {
2200             opcode = tag;
2201         }
2202         @Override
2203         public JCExpression getOperand(OperandPos pos) {
2204             return arg;
2205         }
2206     }
2207 
2208     /**
2209      * A binary operation.
2210      */
2211     public static class JCBinary extends JCOperatorExpression implements BinaryTree {
2212         public JCExpression lhs;
2213         public JCExpression rhs;
2214         protected JCBinary(Tag opcode,
2215                          JCExpression lhs,
2216                          JCExpression rhs,
2217                          OperatorSymbol operator) {
2218             this.opcode = opcode;
2219             this.lhs = lhs;
2220             this.rhs = rhs;
2221             this.operator = operator;
2222         }
2223         @Override
2224         public void accept(Visitor v) { v.visitBinary(this); }
2225 
2226         @DefinedBy(Api.COMPILER_TREE)
2227         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2228         @DefinedBy(Api.COMPILER_TREE)
2229         public JCExpression getLeftOperand() { return lhs; }
2230         @DefinedBy(Api.COMPILER_TREE)
2231         public JCExpression getRightOperand() { return rhs; }
2232         @Override @DefinedBy(Api.COMPILER_TREE)
2233         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2234             return v.visitBinary(this, d);
2235         }
2236         @Override
2237         public JCExpression getOperand(OperandPos pos) {
2238             return pos == OperandPos.LEFT ? lhs : rhs;
2239         }
2240     }
2241 
2242     /**
2243      * A type cast.
2244      */
2245     public static class JCTypeCast extends JCExpression implements TypeCastTree {
2246         public JCTree clazz;
2247         public JCExpression expr;
2248         protected JCTypeCast(JCTree clazz, JCExpression expr) {
2249             this.clazz = clazz;
2250             this.expr = expr;
2251         }
2252         @Override
2253         public void accept(Visitor v) { v.visitTypeCast(this); }
2254 
2255         @DefinedBy(Api.COMPILER_TREE)
2256         public Kind getKind() { return Kind.TYPE_CAST; }
2257         @DefinedBy(Api.COMPILER_TREE)
2258         public JCTree getType() { return clazz; }
2259         @DefinedBy(Api.COMPILER_TREE)
2260         public JCExpression getExpression() { return expr; }
2261         @Override @DefinedBy(Api.COMPILER_TREE)
2262         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2263             return v.visitTypeCast(this, d);
2264         }
2265         @Override
2266         public Tag getTag() {
2267             return TYPECAST;
2268         }
2269     }
2270 
2271     /**
2272      * A type test.
2273      */
2274     public static class JCInstanceOf extends JCExpression implements InstanceOfTree {
2275         public JCExpression expr;
2276         public JCTree pattern;
2277         protected JCInstanceOf(JCExpression expr, JCTree pattern) {
2278             this.expr = expr;
2279             this.pattern = pattern;
2280         }
2281         @Override
2282         public void accept(Visitor v) { v.visitTypeTest(this); }
2283 
2284         @DefinedBy(Api.COMPILER_TREE)
2285         public Kind getKind() { return Kind.INSTANCE_OF; }
2286         @DefinedBy(Api.COMPILER_TREE)
2287         public JCTree getType() { return pattern instanceof JCPattern ? pattern.hasTag(BINDINGPATTERN) ? ((JCBindingPattern) pattern).var.vartype : null : pattern; }
2288 
2289         @Override @DefinedBy(Api.COMPILER_TREE)
2290         public JCPattern getPattern() {
2291             return pattern instanceof JCPattern jcPattern ? jcPattern : null;
2292         }
2293 
2294         @DefinedBy(Api.COMPILER_TREE)
2295         public JCExpression getExpression() { return expr; }
2296         @Override @DefinedBy(Api.COMPILER_TREE)
2297         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2298             return v.visitInstanceOf(this, d);
2299         }
2300         @Override
2301         public Tag getTag() {
2302             return TYPETEST;
2303         }
2304     }
2305 
2306     /**
2307      * Pattern matching forms.
2308      */
2309     public abstract static class JCPattern extends JCCaseLabel
2310             implements PatternTree {
2311 
2312         @Override
2313         public boolean isExpression() {
2314             return false;
2315         }
2316 
2317         @Override
2318         public boolean isPattern() {
2319             return true;
2320         }
2321     }
2322 
2323     public static class JCBindingPattern extends JCPattern
2324             implements BindingPatternTree {
2325         public JCVariableDecl var;
2326 
2327         protected JCBindingPattern(JCVariableDecl var) {
2328             this.var = var;
2329         }
2330 
2331         @Override @DefinedBy(Api.COMPILER_TREE)
2332         public VariableTree getVariable() {
2333             return var;
2334         }
2335 
2336         @Override
2337         public void accept(Visitor v) {
2338             v.visitBindingPattern(this);
2339         }
2340 
2341         @DefinedBy(Api.COMPILER_TREE)
2342         public Kind getKind() {
2343             return Kind.BINDING_PATTERN;
2344         }
2345 
2346         @Override
2347         @DefinedBy(Api.COMPILER_TREE)
2348         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2349             return v.visitBindingPattern(this, d);
2350         }
2351 
2352         @Override
2353         public Tag getTag() {
2354             return BINDINGPATTERN;
2355         }
2356     }
2357 
2358     public static class JCDefaultCaseLabel extends JCCaseLabel
2359             implements DefaultCaseLabelTree {
2360 
2361         protected JCDefaultCaseLabel() {
2362         }
2363 
2364         @Override
2365         public void accept(Visitor v) {
2366             v.visitDefaultCaseLabel(this);
2367         }
2368 
2369         @DefinedBy(Api.COMPILER_TREE)
2370         public Kind getKind() {
2371             return Kind.DEFAULT_CASE_LABEL;
2372         }
2373 
2374         @Override
2375         @DefinedBy(Api.COMPILER_TREE)
2376         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2377             return v.visitDefaultCaseLabel(this, d);
2378         }
2379 
2380         @Override
2381         public Tag getTag() {
2382             return DEFAULTCASELABEL;
2383         }
2384 
2385         @Override
2386         public boolean isExpression() {
2387             return false;
2388         }
2389 
2390         @Override
2391         public boolean isPattern() {
2392             return false;
2393         }
2394     }
2395 
2396     public static class JCParenthesizedPattern extends JCPattern
2397             implements ParenthesizedPatternTree {
2398         public JCPattern pattern;
2399 
2400         public JCParenthesizedPattern(JCPattern pattern) {
2401             this.pattern = pattern;
2402         }
2403 
2404         @Override @DefinedBy(Api.COMPILER_TREE)
2405         public PatternTree getPattern() {
2406             return pattern;
2407         }
2408 
2409         @Override
2410         public void accept(Visitor v) {
2411             v.visitParenthesizedPattern(this);
2412         }
2413 
2414         @DefinedBy(Api.COMPILER_TREE)
2415         public Kind getKind() {
2416             return Kind.PARENTHESIZED_PATTERN;
2417         }
2418 
2419         @Override
2420         @DefinedBy(Api.COMPILER_TREE)
2421         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2422             return v.visitParenthesizedPattern(this, d);
2423         }
2424 
2425         @Override
2426         public Tag getTag() {
2427             return PARENTHESIZEDPATTERN;
2428         }
2429     }
2430 
2431     public static class JCGuardPattern extends JCPattern
2432             implements GuardedPatternTree {
2433         public JCPattern patt;
2434         public JCExpression expr;
2435 
2436         public JCGuardPattern(JCPattern patt, JCExpression expr) {
2437             this.patt = patt;
2438             this.expr = expr;
2439         }
2440 
2441         @Override @DefinedBy(Api.COMPILER_TREE)
2442         public PatternTree getPattern() {
2443             return patt;
2444         }
2445 
2446         @Override @DefinedBy(Api.COMPILER_TREE)
2447         public ExpressionTree getExpression() {
2448             return expr;
2449         }
2450 
2451         @Override
2452         public void accept(Visitor v) {
2453             v.visitGuardPattern(this);
2454         }
2455 
2456         @DefinedBy(Api.COMPILER_TREE)
2457         public Kind getKind() {
2458             return Kind.GUARDED_PATTERN;
2459         }
2460 
2461         @Override
2462         @DefinedBy(Api.COMPILER_TREE)
2463         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
2464             return v.visitGuardedPattern(this, d);
2465         }
2466 
2467         @Override
2468         public Tag getTag() {
2469             return Tag.GUARDPATTERN;
2470         }
2471     }
2472 
2473     /**
2474      * An array selection
2475      */
2476     public static class JCArrayAccess extends JCExpression implements ArrayAccessTree {
2477         public JCExpression indexed;
2478         public JCExpression index;
2479         protected JCArrayAccess(JCExpression indexed, JCExpression index) {
2480             this.indexed = indexed;
2481             this.index = index;
2482         }
2483         @Override
2484         public void accept(Visitor v) { v.visitIndexed(this); }
2485 
2486         @DefinedBy(Api.COMPILER_TREE)
2487         public Kind getKind() { return Kind.ARRAY_ACCESS; }
2488         @DefinedBy(Api.COMPILER_TREE)
2489         public JCExpression getExpression() { return indexed; }
2490         @DefinedBy(Api.COMPILER_TREE)
2491         public JCExpression getIndex() { return index; }
2492         @Override @DefinedBy(Api.COMPILER_TREE)
2493         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2494             return v.visitArrayAccess(this, d);
2495         }
2496         @Override
2497         public Tag getTag() {
2498             return INDEXED;
2499         }
2500     }
2501 
2502     /**
2503      * Selects through packages and classes
2504      */
2505     public static class JCFieldAccess extends JCExpression implements MemberSelectTree {
2506         /** selected Tree hierarchy */
2507         public JCExpression selected;
2508         /** name of field to select thru */
2509         public Name name;
2510         /** symbol of the selected class */
2511         public Symbol sym;
2512         protected JCFieldAccess(JCExpression selected, Name name, Symbol sym) {
2513             this.selected = selected;
2514             this.name = name;
2515             this.sym = sym;
2516         }
2517         @Override
2518         public void accept(Visitor v) { v.visitSelect(this); }
2519 
2520         @DefinedBy(Api.COMPILER_TREE)
2521         public Kind getKind() { return Kind.MEMBER_SELECT; }
2522         @DefinedBy(Api.COMPILER_TREE)
2523         public JCExpression getExpression() { return selected; }
2524         @Override @DefinedBy(Api.COMPILER_TREE)
2525         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2526             return v.visitMemberSelect(this, d);
2527         }
2528         @DefinedBy(Api.COMPILER_TREE)
2529         public Name getIdentifier() { return name; }
2530         @Override
2531         public Tag getTag() {
2532             return SELECT;
2533         }
2534     }
2535 
2536     /**
2537      * Selects a member expression.
2538      */
2539     public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2540 
2541         public ReferenceMode mode;
2542         public ReferenceKind kind;
2543         public Name name;
2544         public JCExpression expr;
2545         public List<JCExpression> typeargs;
2546         public Symbol sym;
2547         public Type varargsElement;
2548         public PolyKind refPolyKind;
2549         public boolean ownerAccessible;
2550         private OverloadKind overloadKind;
2551         public Type referentType;
2552 
2553         public enum OverloadKind {
2554             OVERLOADED,
2555             UNOVERLOADED,
2556             ERROR
2557         }
2558 
2559         /**
2560          * Javac-dependent classification for member references, based
2561          * on relevant properties w.r.t. code-generation
2562          */
2563         public enum ReferenceKind {
2564             /** super # instMethod */
2565             SUPER(ReferenceMode.INVOKE, false),
2566             /** Type # instMethod */
2567             UNBOUND(ReferenceMode.INVOKE, true),
2568             /** Type # staticMethod */
2569             STATIC(ReferenceMode.INVOKE, false),
2570             /** Expr # instMethod */
2571             BOUND(ReferenceMode.INVOKE, false),
2572             /** Inner # new */
2573             IMPLICIT_INNER(ReferenceMode.NEW, false),
2574             /** Toplevel # new */
2575             TOPLEVEL(ReferenceMode.NEW, false),
2576             /** ArrayType # new */
2577             ARRAY_CTOR(ReferenceMode.NEW, false);
2578 
2579             final ReferenceMode mode;
2580             final boolean unbound;
2581 
2582             private ReferenceKind(ReferenceMode mode, boolean unbound) {
2583                 this.mode = mode;
2584                 this.unbound = unbound;
2585             }
2586 
2587             public boolean isUnbound() {
2588                 return unbound;
2589             }
2590         }
2591 
2592         public JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
2593             this.mode = mode;
2594             this.name = name;
2595             this.expr = expr;
2596             this.typeargs = typeargs;
2597         }
2598         @Override
2599         public void accept(Visitor v) { v.visitReference(this); }
2600 
2601         @DefinedBy(Api.COMPILER_TREE)
2602         public Kind getKind() { return Kind.MEMBER_REFERENCE; }
2603         @Override @DefinedBy(Api.COMPILER_TREE)
2604         public ReferenceMode getMode() { return mode; }
2605         @Override @DefinedBy(Api.COMPILER_TREE)
2606         public JCExpression getQualifierExpression() { return expr; }
2607         @Override @DefinedBy(Api.COMPILER_TREE)
2608         public Name getName() { return name; }
2609         @Override @DefinedBy(Api.COMPILER_TREE)
2610         public List<JCExpression> getTypeArguments() { return typeargs; }
2611 
2612         @Override @DefinedBy(Api.COMPILER_TREE)
2613         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2614             return v.visitMemberReference(this, d);
2615         }
2616         @Override
2617         public Tag getTag() {
2618             return REFERENCE;
2619         }
2620         public boolean hasKind(ReferenceKind kind) {
2621             return this.kind == kind;
2622         }
2623 
2624         /**
2625          * @return the overloadKind
2626          */
2627         public OverloadKind getOverloadKind() {
2628             return overloadKind;
2629         }
2630 
2631         /**
2632          * @param overloadKind the overloadKind to set
2633          */
2634         public void setOverloadKind(OverloadKind overloadKind) {
2635             this.overloadKind = overloadKind;
2636         }
2637     }
2638 
2639     /**
2640      * An identifier
2641      */
2642     public static class JCIdent extends JCExpression implements IdentifierTree {
2643         /** the name */
2644         public Name name;
2645         /** the symbol */
2646         public Symbol sym;
2647         protected JCIdent(Name name, Symbol sym) {
2648             this.name = name;
2649             this.sym = sym;
2650         }
2651         @Override
2652         public void accept(Visitor v) { v.visitIdent(this); }
2653 
2654         @DefinedBy(Api.COMPILER_TREE)
2655         public Kind getKind() { return Kind.IDENTIFIER; }
2656         @DefinedBy(Api.COMPILER_TREE)
2657         public Name getName() { return name; }
2658         @Override @DefinedBy(Api.COMPILER_TREE)
2659         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2660             return v.visitIdentifier(this, d);
2661         }
2662         @Override
2663         public Tag getTag() {
2664             return IDENT;
2665         }
2666     }
2667 
2668     /**
2669      * A constant value given literally.
2670      */
2671     public static class JCLiteral extends JCExpression implements LiteralTree {
2672         public TypeTag typetag;
2673         /** value representation */
2674         public Object value;
2675         protected JCLiteral(TypeTag typetag, Object value) {
2676             this.typetag = typetag;
2677             this.value = value;
2678         }
2679         @Override
2680         public void accept(Visitor v) { v.visitLiteral(this); }
2681 
2682         @DefinedBy(Api.COMPILER_TREE)
2683         public Kind getKind() {
2684             return typetag.getKindLiteral();
2685         }
2686 
2687         @DefinedBy(Api.COMPILER_TREE)
2688         public Object getValue() {
2689             switch (typetag) {
2690                 case BOOLEAN:
2691                     int bi = (Integer) value;
2692                     return (bi != 0);
2693                 case CHAR:
2694                     int ci = (Integer) value;
2695                     char c = (char) ci;
2696                     if (c != ci)
2697                         throw new AssertionError("bad value for char literal");
2698                     return c;
2699                 default:
2700                     return value;
2701             }
2702         }
2703         @Override @DefinedBy(Api.COMPILER_TREE)
2704         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2705             return v.visitLiteral(this, d);
2706         }
2707         @Override
2708         public JCLiteral setType(Type type) {
2709             super.setType(type);
2710             return this;
2711         }
2712         @Override
2713         public Tag getTag() {
2714             return LITERAL;
2715         }
2716     }
2717 
2718     /**
2719      * Identifies a basic type.
2720      * @see TypeTag
2721      */
2722     public static class JCPrimitiveTypeTree extends JCExpression implements PrimitiveTypeTree {
2723         /** the basic type id */
2724         public TypeTag typetag;
2725         protected JCPrimitiveTypeTree(TypeTag typetag) {
2726             this.typetag = typetag;
2727         }
2728         @Override
2729         public void accept(Visitor v) { v.visitTypeIdent(this); }
2730 
2731         @DefinedBy(Api.COMPILER_TREE)
2732         public Kind getKind() { return Kind.PRIMITIVE_TYPE; }
2733         @DefinedBy(Api.COMPILER_TREE)
2734         public TypeKind getPrimitiveTypeKind() {
2735             return typetag.getPrimitiveTypeKind();
2736         }
2737 
2738         @Override @DefinedBy(Api.COMPILER_TREE)
2739         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2740             return v.visitPrimitiveType(this, d);
2741         }
2742         @Override
2743         public Tag getTag() {
2744             return TYPEIDENT;
2745         }
2746     }
2747 
2748     /**
2749      * An array type, A[]
2750      */
2751     public static class JCArrayTypeTree extends JCExpression implements ArrayTypeTree {
2752         public JCExpression elemtype;
2753         protected JCArrayTypeTree(JCExpression elemtype) {
2754             this.elemtype = elemtype;
2755         }
2756         @Override
2757         public void accept(Visitor v) { v.visitTypeArray(this); }
2758 
2759         @DefinedBy(Api.COMPILER_TREE)
2760         public Kind getKind() { return Kind.ARRAY_TYPE; }
2761         @DefinedBy(Api.COMPILER_TREE)
2762         public JCTree getType() { return elemtype; }
2763         @Override @DefinedBy(Api.COMPILER_TREE)
2764         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2765             return v.visitArrayType(this, d);
2766         }
2767         @Override
2768         public Tag getTag() {
2769             return TYPEARRAY;
2770         }
2771     }
2772 
2773     /**
2774      * A parameterized type, {@literal T<...>}
2775      */
2776     public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
2777         public JCExpression clazz;
2778         public List<JCExpression> arguments;
2779         protected JCTypeApply(JCExpression clazz, List<JCExpression> arguments) {
2780             this.clazz = clazz;
2781             this.arguments = arguments;
2782         }
2783         @Override
2784         public void accept(Visitor v) { v.visitTypeApply(this); }
2785 
2786         @DefinedBy(Api.COMPILER_TREE)
2787         public Kind getKind() { return Kind.PARAMETERIZED_TYPE; }
2788         @DefinedBy(Api.COMPILER_TREE)
2789         public JCTree getType() { return clazz; }
2790         @DefinedBy(Api.COMPILER_TREE)
2791         public List<JCExpression> getTypeArguments() {
2792             return arguments;
2793         }
2794         @Override @DefinedBy(Api.COMPILER_TREE)
2795         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2796             return v.visitParameterizedType(this, d);
2797         }
2798         @Override
2799         public Tag getTag() {
2800             return TYPEAPPLY;
2801         }
2802     }
2803 
2804     /**
2805      * A union type, T1 | T2 | ... Tn (used in multicatch statements)
2806      */
2807     public static class JCTypeUnion extends JCExpression implements UnionTypeTree {
2808 
2809         public List<JCExpression> alternatives;
2810 
2811         protected JCTypeUnion(List<JCExpression> components) {
2812             this.alternatives = components;
2813         }
2814         @Override
2815         public void accept(Visitor v) { v.visitTypeUnion(this); }
2816 
2817         @DefinedBy(Api.COMPILER_TREE)
2818         public Kind getKind() { return Kind.UNION_TYPE; }
2819 
2820         @DefinedBy(Api.COMPILER_TREE)
2821         public List<JCExpression> getTypeAlternatives() {
2822             return alternatives;
2823         }
2824         @Override @DefinedBy(Api.COMPILER_TREE)
2825         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2826             return v.visitUnionType(this, d);
2827         }
2828         @Override
2829         public Tag getTag() {
2830             return TYPEUNION;
2831         }
2832     }
2833 
2834     /**
2835      * An intersection type, {@code T1 & T2 & ... Tn} (used in cast expressions)
2836      */
2837     public static class JCTypeIntersection extends JCExpression implements IntersectionTypeTree {
2838 
2839         public List<JCExpression> bounds;
2840 
2841         protected JCTypeIntersection(List<JCExpression> bounds) {
2842             this.bounds = bounds;
2843         }
2844         @Override
2845         public void accept(Visitor v) { v.visitTypeIntersection(this); }
2846 
2847         @DefinedBy(Api.COMPILER_TREE)
2848         public Kind getKind() { return Kind.INTERSECTION_TYPE; }
2849 
2850         @DefinedBy(Api.COMPILER_TREE)
2851         public List<JCExpression> getBounds() {
2852             return bounds;
2853         }
2854         @Override @DefinedBy(Api.COMPILER_TREE)
2855         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2856             return v.visitIntersectionType(this, d);
2857         }
2858         @Override
2859         public Tag getTag() {
2860             return TYPEINTERSECTION;
2861         }
2862     }
2863 
2864     /**
2865      * A formal class parameter.
2866      */
2867     public static class JCTypeParameter extends JCTree implements TypeParameterTree {
2868         /** name */
2869         public Name name;
2870         /** bounds */
2871         public List<JCExpression> bounds;
2872         /** type annotations on type parameter */
2873         public List<JCAnnotation> annotations;
2874         protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCAnnotation> annotations) {
2875             this.name = name;
2876             this.bounds = bounds;
2877             this.annotations = annotations;
2878         }
2879         @Override
2880         public void accept(Visitor v) { v.visitTypeParameter(this); }
2881 
2882         @DefinedBy(Api.COMPILER_TREE)
2883         public Kind getKind() { return Kind.TYPE_PARAMETER; }
2884         @DefinedBy(Api.COMPILER_TREE)
2885         public Name getName() { return name; }
2886         @DefinedBy(Api.COMPILER_TREE)
2887         public List<JCExpression> getBounds() {
2888             return bounds;
2889         }
2890         @DefinedBy(Api.COMPILER_TREE)
2891         public List<JCAnnotation> getAnnotations() {
2892             return annotations;
2893         }
2894         @Override @DefinedBy(Api.COMPILER_TREE)
2895         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2896             return v.visitTypeParameter(this, d);
2897         }
2898         @Override
2899         public Tag getTag() {
2900             return TYPEPARAMETER;
2901         }
2902     }
2903 
2904     public static class JCWildcard extends JCExpression implements WildcardTree {
2905         public TypeBoundKind kind;
2906         public JCTree inner;
2907         protected JCWildcard(TypeBoundKind kind, JCTree inner) {
2908             this.kind = Assert.checkNonNull(kind);
2909             this.inner = inner;
2910         }
2911         @Override
2912         public void accept(Visitor v) { v.visitWildcard(this); }
2913 
2914         @DefinedBy(Api.COMPILER_TREE)
2915         public Kind getKind() {
2916             switch (kind.kind) {
2917             case UNBOUND:
2918                 return Kind.UNBOUNDED_WILDCARD;
2919             case EXTENDS:
2920                 return Kind.EXTENDS_WILDCARD;
2921             case SUPER:
2922                 return Kind.SUPER_WILDCARD;
2923             default:
2924                 throw new AssertionError("Unknown wildcard bound " + kind);
2925             }
2926         }
2927         @DefinedBy(Api.COMPILER_TREE)
2928         public JCTree getBound() { return inner; }
2929         @Override @DefinedBy(Api.COMPILER_TREE)
2930         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2931             return v.visitWildcard(this, d);
2932         }
2933         @Override
2934         public Tag getTag() {
2935             return Tag.WILDCARD;
2936         }
2937     }
2938 
2939     public static class TypeBoundKind extends JCTree {
2940         public BoundKind kind;
2941         protected TypeBoundKind(BoundKind kind) {
2942             this.kind = kind;
2943         }
2944         @Override
2945         public void accept(Visitor v) { v.visitTypeBoundKind(this); }
2946 
2947         @DefinedBy(Api.COMPILER_TREE)
2948         public Kind getKind() {
2949             throw new AssertionError("TypeBoundKind is not part of a public API");
2950         }
2951         @Override @DefinedBy(Api.COMPILER_TREE)
2952         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2953             throw new AssertionError("TypeBoundKind is not part of a public API");
2954         }
2955         @Override
2956         public Tag getTag() {
2957             return TYPEBOUNDKIND;
2958         }
2959     }
2960 
2961     public static class JCAnnotation extends JCExpression implements AnnotationTree {
2962         // Either Tag.ANNOTATION or Tag.TYPE_ANNOTATION
2963         private Tag tag;
2964 
2965         public JCTree annotationType;
2966         public List<JCExpression> args;
2967         public Attribute.Compound attribute;
2968 
2969         protected JCAnnotation(Tag tag, JCTree annotationType, List<JCExpression> args) {
2970             this.tag = tag;
2971             this.annotationType = annotationType;
2972             this.args = args;
2973         }
2974 
2975         @Override
2976         public void accept(Visitor v) { v.visitAnnotation(this); }
2977 
2978         @DefinedBy(Api.COMPILER_TREE)
2979         public Kind getKind() { return TreeInfo.tagToKind(getTag()); }
2980 
2981         @DefinedBy(Api.COMPILER_TREE)
2982         public JCTree getAnnotationType() { return annotationType; }
2983         @DefinedBy(Api.COMPILER_TREE)
2984         public List<JCExpression> getArguments() {
2985             return args;
2986         }
2987         @Override @DefinedBy(Api.COMPILER_TREE)
2988         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2989             return v.visitAnnotation(this, d);
2990         }
2991         @Override
2992         public Tag getTag() {
2993             return tag;
2994         }
2995     }
2996 
2997     public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
2998         public long flags;
2999         public List<JCAnnotation> annotations;
3000         protected JCModifiers(long flags, List<JCAnnotation> annotations) {
3001             this.flags = flags;
3002             this.annotations = annotations;
3003         }
3004         @Override
3005         public void accept(Visitor v) { v.visitModifiers(this); }
3006 
3007         @DefinedBy(Api.COMPILER_TREE)
3008         public Kind getKind() { return Kind.MODIFIERS; }
3009         @DefinedBy(Api.COMPILER_TREE)
3010         public Set<Modifier> getFlags() {
3011             return Flags.asModifierSet(flags);
3012         }
3013         @DefinedBy(Api.COMPILER_TREE)
3014         public List<JCAnnotation> getAnnotations() {
3015             return annotations;
3016         }
3017         @Override @DefinedBy(Api.COMPILER_TREE)
3018         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3019             return v.visitModifiers(this, d);
3020         }
3021         @Override
3022         public Tag getTag() {
3023             return MODIFIERS;
3024         }
3025     }
3026 
3027     public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
3028         // type annotations
3029         public List<JCAnnotation> annotations;
3030         public JCExpression underlyingType;
3031 
3032         protected JCAnnotatedType(List<JCAnnotation> annotations, JCExpression underlyingType) {
3033             Assert.check(annotations != null && annotations.nonEmpty());
3034             this.annotations = annotations;
3035             this.underlyingType = underlyingType;
3036         }
3037         @Override
3038         public void accept(Visitor v) { v.visitAnnotatedType(this); }
3039 
3040         @DefinedBy(Api.COMPILER_TREE)
3041         public Kind getKind() { return Kind.ANNOTATED_TYPE; }
3042         @DefinedBy(Api.COMPILER_TREE)
3043         public List<JCAnnotation> getAnnotations() {
3044             return annotations;
3045         }
3046         @DefinedBy(Api.COMPILER_TREE)
3047         public JCExpression getUnderlyingType() {
3048             return underlyingType;
3049         }
3050         @Override @DefinedBy(Api.COMPILER_TREE)
3051         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3052             return v.visitAnnotatedType(this, d);
3053         }
3054         @Override
3055         public Tag getTag() {
3056             return ANNOTATED_TYPE;
3057         }
3058     }
3059 
3060     public abstract static class JCDirective extends JCTree
3061         implements DirectiveTree {
3062     }
3063 
3064     public static class JCModuleDecl extends JCTree implements ModuleTree {
3065         public JCModifiers mods;
3066         public ModuleType type;
3067         private final ModuleKind kind;
3068         public JCExpression qualId;
3069         public List<JCDirective> directives;
3070         public ModuleSymbol sym;
3071 
3072         protected JCModuleDecl(JCModifiers mods, ModuleKind kind,
3073                 JCExpression qualId, List<JCDirective> directives) {
3074             this.mods = mods;
3075             this.kind = kind;
3076             this.qualId = qualId;
3077             this.directives = directives;
3078         }
3079 
3080         @Override
3081         public void accept(Visitor v) { v.visitModuleDef(this); }
3082 
3083         @Override @DefinedBy(Api.COMPILER_TREE)
3084         public Kind getKind() {
3085             return Kind.MODULE;
3086         }
3087 
3088         @Override @DefinedBy(Api.COMPILER_TREE)
3089         public List<? extends AnnotationTree> getAnnotations() {
3090             return mods.annotations;
3091         }
3092 
3093         @Override @DefinedBy(Api.COMPILER_TREE)
3094         public ModuleKind getModuleType() {
3095             return kind;
3096         }
3097 
3098         @Override @DefinedBy(Api.COMPILER_TREE)
3099         public JCExpression getName() {
3100             return qualId;
3101         }
3102 
3103         @Override @DefinedBy(Api.COMPILER_TREE)
3104         public List<JCDirective> getDirectives() {
3105             return directives;
3106         }
3107 
3108         @Override @DefinedBy(Api.COMPILER_TREE)
3109         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3110             return v.visitModule(this, d);
3111         }
3112 
3113         @Override
3114         public Tag getTag() {
3115             return MODULEDEF;
3116         }
3117     }
3118 
3119     public static class JCExports extends JCDirective
3120             implements ExportsTree {
3121         public JCExpression qualid;
3122         public List<JCExpression> moduleNames;
3123         public ExportsDirective directive;
3124 
3125         protected JCExports(JCExpression qualId, List<JCExpression> moduleNames) {
3126             this.qualid = qualId;
3127             this.moduleNames = moduleNames;
3128         }
3129 
3130         @Override
3131         public void accept(Visitor v) { v.visitExports(this); }
3132 
3133         @Override @DefinedBy(Api.COMPILER_TREE)
3134         public Kind getKind() {
3135             return Kind.EXPORTS;
3136         }
3137 
3138         @Override @DefinedBy(Api.COMPILER_TREE)
3139         public JCExpression getPackageName() {
3140             return qualid;
3141         }
3142 
3143         @Override @DefinedBy(Api.COMPILER_TREE)
3144         public List<JCExpression> getModuleNames() {
3145             return moduleNames;
3146         }
3147 
3148         @Override @DefinedBy(Api.COMPILER_TREE)
3149         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3150             return v.visitExports(this, d);
3151         }
3152 
3153         @Override
3154         public Tag getTag() {
3155             return Tag.EXPORTS;
3156         }
3157     }
3158 
3159     public static class JCOpens extends JCDirective
3160             implements OpensTree {
3161         public JCExpression qualid;
3162         public List<JCExpression> moduleNames;
3163         public OpensDirective directive;
3164 
3165         protected JCOpens(JCExpression qualId, List<JCExpression> moduleNames) {
3166             this.qualid = qualId;
3167             this.moduleNames = moduleNames;
3168         }
3169 
3170         @Override
3171         public void accept(Visitor v) { v.visitOpens(this); }
3172 
3173         @Override @DefinedBy(Api.COMPILER_TREE)
3174         public Kind getKind() {
3175             return Kind.OPENS;
3176         }
3177 
3178         @Override @DefinedBy(Api.COMPILER_TREE)
3179         public JCExpression getPackageName() {
3180             return qualid;
3181         }
3182 
3183         @Override @DefinedBy(Api.COMPILER_TREE)
3184         public List<JCExpression> getModuleNames() {
3185             return moduleNames;
3186         }
3187 
3188         @Override @DefinedBy(Api.COMPILER_TREE)
3189         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3190             return v.visitOpens(this, d);
3191         }
3192 
3193         @Override
3194         public Tag getTag() {
3195             return Tag.OPENS;
3196         }
3197     }
3198 
3199     public static class JCProvides extends JCDirective
3200             implements ProvidesTree {
3201         public JCExpression serviceName;
3202         public List<JCExpression> implNames;
3203 
3204         protected JCProvides(JCExpression serviceName, List<JCExpression> implNames) {
3205             this.serviceName = serviceName;
3206             this.implNames = implNames;
3207         }
3208 
3209         @Override
3210         public void accept(Visitor v) { v.visitProvides(this); }
3211 
3212         @Override @DefinedBy(Api.COMPILER_TREE)
3213         public Kind getKind() {
3214             return Kind.PROVIDES;
3215         }
3216 
3217         @Override @DefinedBy(Api.COMPILER_TREE)
3218         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3219             return v.visitProvides(this, d);
3220         }
3221 
3222         @Override @DefinedBy(Api.COMPILER_TREE)
3223         public JCExpression getServiceName() {
3224             return serviceName;
3225         }
3226 
3227         @Override @DefinedBy(Api.COMPILER_TREE)
3228         public List<JCExpression> getImplementationNames() {
3229             return implNames;
3230         }
3231 
3232         @Override
3233         public Tag getTag() {
3234             return PROVIDES;
3235         }
3236     }
3237 
3238     public static class JCRequires extends JCDirective
3239             implements RequiresTree {
3240         public boolean isTransitive;
3241         public boolean isStaticPhase;
3242         public JCExpression moduleName;
3243         public RequiresDirective directive;
3244 
3245         protected JCRequires(boolean isTransitive, boolean isStaticPhase, JCExpression moduleName) {
3246             this.isTransitive = isTransitive;
3247             this.isStaticPhase = isStaticPhase;
3248             this.moduleName = moduleName;
3249         }
3250 
3251         @Override
3252         public void accept(Visitor v) { v.visitRequires(this); }
3253 
3254         @Override @DefinedBy(Api.COMPILER_TREE)
3255         public Kind getKind() {
3256             return Kind.REQUIRES;
3257         }
3258 
3259         @Override @DefinedBy(Api.COMPILER_TREE)
3260         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3261             return v.visitRequires(this, d);
3262         }
3263 
3264         @Override @DefinedBy(Api.COMPILER_TREE)
3265         public boolean isTransitive() {
3266             return isTransitive;
3267         }
3268 
3269         @Override @DefinedBy(Api.COMPILER_TREE)
3270         public boolean isStatic() {
3271             return isStaticPhase;
3272         }
3273 
3274         @Override @DefinedBy(Api.COMPILER_TREE)
3275         public JCExpression getModuleName() {
3276             return moduleName;
3277         }
3278 
3279         @Override
3280         public Tag getTag() {
3281             return REQUIRES;
3282         }
3283     }
3284 
3285     public static class JCUses extends JCDirective
3286             implements UsesTree {
3287         public JCExpression qualid;
3288 
3289         protected JCUses(JCExpression qualId) {
3290             this.qualid = qualId;
3291         }
3292 
3293         @Override
3294         public void accept(Visitor v) { v.visitUses(this); }
3295 
3296         @Override @DefinedBy(Api.COMPILER_TREE)
3297         public Kind getKind() {
3298             return Kind.USES;
3299         }
3300 
3301         @Override @DefinedBy(Api.COMPILER_TREE)
3302         public JCExpression getServiceName() {
3303             return qualid;
3304         }
3305 
3306         @Override @DefinedBy(Api.COMPILER_TREE)
3307         public <R, D> R accept(TreeVisitor<R, D> v, D d) {
3308             return v.visitUses(this, d);
3309         }
3310 
3311         @Override
3312         public Tag getTag() {
3313             return USES;
3314         }
3315     }
3316 
3317     public static class JCErroneous extends JCExpression
3318             implements ErroneousTree {
3319         public List<? extends JCTree> errs;
3320         protected JCErroneous(List<? extends JCTree> errs) {
3321             this.errs = errs;
3322         }
3323         @Override
3324         public void accept(Visitor v) { v.visitErroneous(this); }
3325 
3326         @DefinedBy(Api.COMPILER_TREE)
3327         public Kind getKind() { return Kind.ERRONEOUS; }
3328 
3329         @DefinedBy(Api.COMPILER_TREE)
3330         public List<? extends JCTree> getErrorTrees() {
3331             return errs;
3332         }
3333 
3334         @Override @DefinedBy(Api.COMPILER_TREE)
3335         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3336             return v.visitErroneous(this, d);
3337         }
3338         @Override
3339         public Tag getTag() {
3340             return ERRONEOUS;
3341         }
3342     }
3343 
3344     /** (let int x = 3; in x+2) */
3345     public static class LetExpr extends JCExpression {
3346         public List<JCStatement> defs;
3347         public JCExpression expr;
3348         /**true if a expr should be run through Gen.genCond:*/
3349         public boolean needsCond;
3350         protected LetExpr(List<JCStatement> defs, JCExpression expr) {
3351             this.defs = defs;
3352             this.expr = expr;
3353         }
3354         @Override
3355         public void accept(Visitor v) { v.visitLetExpr(this); }
3356 
3357         @DefinedBy(Api.COMPILER_TREE)
3358         public Kind getKind() {
3359             throw new AssertionError("LetExpr is not part of a public API");
3360         }
3361         @Override @DefinedBy(Api.COMPILER_TREE)
3362         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
3363             throw new AssertionError("LetExpr is not part of a public API");
3364         }
3365         @Override
3366         public Tag getTag() {
3367             return LETEXPR;
3368         }
3369     }
3370 
3371     /** An interface for tree factories
3372      */
3373     public interface Factory {
3374         JCCompilationUnit TopLevel(List<JCTree> defs);
3375         JCPackageDecl PackageDecl(List<JCAnnotation> annotations,
3376                                   JCExpression pid);
3377         JCImport Import(JCTree qualid, boolean staticImport);
3378         JCClassDecl ClassDef(JCModifiers mods,
3379                           Name name,
3380                           List<JCTypeParameter> typarams,
3381                           JCExpression extending,
3382                           List<JCExpression> implementing,
3383                           List<JCTree> defs);
3384         JCMethodDecl MethodDef(JCModifiers mods,
3385                             Name name,
3386                             JCExpression restype,
3387                             List<JCTypeParameter> typarams,
3388                             JCVariableDecl recvparam,
3389                             List<JCVariableDecl> params,
3390                             List<JCExpression> thrown,
3391                             JCBlock body,
3392                             JCExpression defaultValue);
3393         JCVariableDecl VarDef(JCModifiers mods,
3394                       Name name,
3395                       JCExpression vartype,
3396                       JCExpression init);
3397         JCSkip Skip();
3398         JCBlock Block(long flags, List<JCStatement> stats);
3399         JCDoWhileLoop DoLoop(JCStatement body, JCExpression cond);
3400         JCWhileLoop WhileLoop(JCExpression cond, JCStatement body);
3401         JCForLoop ForLoop(List<JCStatement> init,
3402                         JCExpression cond,
3403                         List<JCExpressionStatement> step,
3404                         JCStatement body);
3405         JCEnhancedForLoop ForeachLoop(JCVariableDecl var, JCExpression expr, JCStatement body);
3406         JCLabeledStatement Labelled(Name label, JCStatement body);
3407         JCSwitch Switch(JCExpression selector, List<JCCase> cases);
3408         JCSwitchExpression SwitchExpression(JCExpression selector, List<JCCase> cases);
3409         JCCase Case(CaseTree.CaseKind caseKind, List<JCCaseLabel> labels,
3410                     List<JCStatement> stats, JCTree body);
3411         JCDefaultValue DefaultValue(JCExpression type);
3412         JCSynchronized Synchronized(JCExpression lock, JCBlock body);
3413         JCTry Try(JCBlock body, List<JCCatch> catchers, JCBlock finalizer);
3414         JCTry Try(List<JCTree> resources,
3415                   JCBlock body,
3416                   List<JCCatch> catchers,
3417                   JCBlock finalizer);
3418         JCCatch Catch(JCVariableDecl param, JCBlock body);
3419         JCConditional Conditional(JCExpression cond,
3420                                 JCExpression thenpart,
3421                                 JCExpression elsepart);
3422         JCIf If(JCExpression cond, JCStatement thenpart, JCStatement elsepart);
3423         JCExpressionStatement Exec(JCExpression expr);
3424         JCBreak Break(Name label);
3425         JCYield Yield(JCExpression value);
3426         JCContinue Continue(Name label);
3427         JCReturn Return(JCExpression expr);
3428         JCThrow Throw(JCExpression expr);
3429         JCAssert Assert(JCExpression cond, JCExpression detail);
3430         JCMethodInvocation Apply(List<JCExpression> typeargs,
3431                     JCExpression fn,
3432                     List<JCExpression> args);
3433         JCNewClass NewClass(JCExpression encl,
3434                           List<JCExpression> typeargs,
3435                           JCExpression clazz,
3436                           List<JCExpression> args,
3437                           JCClassDecl def);
3438         JCNewArray NewArray(JCExpression elemtype,
3439                           List<JCExpression> dims,
3440                           List<JCExpression> elems);
3441         JCParens Parens(JCExpression expr);
3442         JCAssign Assign(JCExpression lhs, JCExpression rhs);
3443         JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs);
3444         JCUnary Unary(Tag opcode, JCExpression arg);
3445         JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs);
3446         JCTypeCast TypeCast(JCTree expr, JCExpression type);
3447         JCInstanceOf TypeTest(JCExpression expr, JCTree clazz);
3448         JCBindingPattern BindingPattern(JCVariableDecl var);
3449         JCArrayAccess Indexed(JCExpression indexed, JCExpression index);
3450         JCFieldAccess Select(JCExpression selected, Name selector);
3451         JCIdent Ident(Name idname);
3452         JCLiteral Literal(TypeTag tag, Object value);
3453         JCPrimitiveTypeTree TypeIdent(TypeTag typetag);
3454         JCArrayTypeTree TypeArray(JCExpression elemtype);
3455         JCTypeApply TypeApply(JCExpression clazz, List<JCExpression> arguments);
3456         JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds);
3457         JCWildcard Wildcard(TypeBoundKind kind, JCTree type);
3458         TypeBoundKind TypeBoundKind(BoundKind kind);
3459         JCAnnotation Annotation(JCTree annotationType, List<JCExpression> args);
3460         JCModifiers Modifiers(long flags, List<JCAnnotation> annotations);
3461         JCErroneous Erroneous(List<? extends JCTree> errs);
3462         JCModuleDecl ModuleDef(JCModifiers mods, ModuleKind kind, JCExpression qualId, List<JCDirective> directives);
3463         JCExports Exports(JCExpression qualId, List<JCExpression> moduleNames);
3464         JCOpens Opens(JCExpression qualId, List<JCExpression> moduleNames);
3465         JCProvides Provides(JCExpression serviceName, List<JCExpression> implNames);
3466         JCRequires Requires(boolean isTransitive, boolean isStaticPhase, JCExpression qualId);
3467         JCUses Uses(JCExpression qualId);
3468         LetExpr LetExpr(List<JCStatement> defs, JCExpression expr);
3469     }
3470 
3471     /** A generic visitor class for trees.
3472      */
3473     public abstract static class Visitor {
3474         public void visitTopLevel(JCCompilationUnit that)    { visitTree(that); }
3475         public void visitPackageDef(JCPackageDecl that)      { visitTree(that); }
3476         public void visitImport(JCImport that)               { visitTree(that); }
3477         public void visitClassDef(JCClassDecl that)          { visitTree(that); }
3478         public void visitMethodDef(JCMethodDecl that)        { visitTree(that); }
3479         public void visitVarDef(JCVariableDecl that)         { visitTree(that); }
3480         public void visitSkip(JCSkip that)                   { visitTree(that); }
3481         public void visitBlock(JCBlock that)                 { visitTree(that); }
3482         public void visitDoLoop(JCDoWhileLoop that)          { visitTree(that); }
3483         public void visitWhileLoop(JCWhileLoop that)         { visitTree(that); }
3484         public void visitWithField(JCWithField that)         { visitTree(that); }
3485         public void visitForLoop(JCForLoop that)             { visitTree(that); }
3486         public void visitForeachLoop(JCEnhancedForLoop that) { visitTree(that); }
3487         public void visitLabelled(JCLabeledStatement that)   { visitTree(that); }
3488         public void visitSwitch(JCSwitch that)               { visitTree(that); }
3489         public void visitCase(JCCase that)                   { visitTree(that); }
3490         public void visitDefaultValue(JCDefaultValue that) { visitTree(that); }
3491         public void visitSwitchExpression(JCSwitchExpression that)               { visitTree(that); }
3492         public void visitSynchronized(JCSynchronized that)   { visitTree(that); }
3493         public void visitTry(JCTry that)                     { visitTree(that); }
3494         public void visitCatch(JCCatch that)                 { visitTree(that); }
3495         public void visitConditional(JCConditional that)     { visitTree(that); }
3496         public void visitIf(JCIf that)                       { visitTree(that); }
3497         public void visitExec(JCExpressionStatement that)    { visitTree(that); }
3498         public void visitBreak(JCBreak that)                 { visitTree(that); }
3499         public void visitYield(JCYield that)                 { visitTree(that); }
3500         public void visitContinue(JCContinue that)           { visitTree(that); }
3501         public void visitReturn(JCReturn that)               { visitTree(that); }
3502         public void visitThrow(JCThrow that)                 { visitTree(that); }
3503         public void visitAssert(JCAssert that)               { visitTree(that); }
3504         public void visitApply(JCMethodInvocation that)      { visitTree(that); }
3505         public void visitNewClass(JCNewClass that)           { visitTree(that); }
3506         public void visitNewArray(JCNewArray that)           { visitTree(that); }
3507         public void visitLambda(JCLambda that)               { visitTree(that); }
3508         public void visitParens(JCParens that)               { visitTree(that); }
3509         public void visitAssign(JCAssign that)               { visitTree(that); }
3510         public void visitAssignop(JCAssignOp that)           { visitTree(that); }
3511         public void visitUnary(JCUnary that)                 { visitTree(that); }
3512         public void visitBinary(JCBinary that)               { visitTree(that); }
3513         public void visitTypeCast(JCTypeCast that)           { visitTree(that); }
3514         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
3515         public void visitBindingPattern(JCBindingPattern that) { visitTree(that); }
3516         public void visitDefaultCaseLabel(JCDefaultCaseLabel that) { visitTree(that); }
3517         public void visitParenthesizedPattern(JCParenthesizedPattern that) { visitTree(that); }
3518         public void visitGuardPattern(JCGuardPattern that) { visitTree(that); }
3519         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
3520         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
3521         public void visitReference(JCMemberReference that)   { visitTree(that); }
3522         public void visitIdent(JCIdent that)                 { visitTree(that); }
3523         public void visitLiteral(JCLiteral that)             { visitTree(that); }
3524         public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
3525         public void visitTypeArray(JCArrayTypeTree that)     { visitTree(that); }
3526         public void visitTypeApply(JCTypeApply that)         { visitTree(that); }
3527         public void visitTypeUnion(JCTypeUnion that)         { visitTree(that); }
3528         public void visitTypeIntersection(JCTypeIntersection that)  { visitTree(that); }
3529         public void visitTypeParameter(JCTypeParameter that) { visitTree(that); }
3530         public void visitWildcard(JCWildcard that)           { visitTree(that); }
3531         public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
3532         public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
3533         public void visitModifiers(JCModifiers that)         { visitTree(that); }
3534         public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
3535         public void visitErroneous(JCErroneous that)         { visitTree(that); }
3536         public void visitModuleDef(JCModuleDecl that)        { visitTree(that); }
3537         public void visitExports(JCExports that)             { visitTree(that); }
3538         public void visitOpens(JCOpens that)                 { visitTree(that); }
3539         public void visitProvides(JCProvides that)           { visitTree(that); }
3540         public void visitRequires(JCRequires that)           { visitTree(that); }
3541         public void visitUses(JCUses that)                   { visitTree(that); }
3542         public void visitLetExpr(LetExpr that)               { visitTree(that); }
3543 
3544         public void visitTree(JCTree that)                   { Assert.error(); }
3545     }
3546 
3547 }