783 /**
784 * A poly expression can only be truly 'poly' in certain contexts
785 */
786 public enum PolyKind {
787 /** poly expression to be treated as a standalone expression */
788 STANDALONE,
789 /** true poly expression */
790 POLY
791 }
792
793 /** is this poly expression a 'true' poly expression? */
794 public PolyKind polyKind;
795
796 @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
797 @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
798 }
799
800 /**
801 * Common supertype for all functional expression trees (lambda and method references)
802 */
803 public abstract static class JCFunctionalExpression extends JCPolyExpression {
804
805 public JCFunctionalExpression() {
806 //a functional expression is always a 'true' poly
807 polyKind = PolyKind.POLY;
808 }
809
810 /** list of target types inferred for this functional expression. */
811 public Type target;
812 /** The owner of this functional expression. */
813 public Symbol owner;
814
815 public Type getDescriptorType(Types types) {
816 return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
817 }
818 }
819
820 /**
821 * A class definition.
822 */
823 public static class JCClassDecl extends JCStatement implements ClassTree {
824 /** the modifiers */
825 public JCModifiers mods;
826 /** the name of the class */
827 public Name name;
828 /** formal class parameters */
829 public List<JCTypeParameter> typarams;
830 /** the classes this class extends */
831 public JCExpression extending;
832 /** the interfaces implemented by this class */
833 public List<JCExpression> implementing;
834 /** the subclasses allowed to extend this class, if sealed */
835 public List<JCExpression> permitting;
836 /** all variables and methods defined in this class */
1988 }
1989 @Override
1990 public Tag getTag() {
1991 return NEWARRAY;
1992 }
1993
1994 @Override @DefinedBy(Api.COMPILER_TREE)
1995 public List<JCAnnotation> getAnnotations() {
1996 return annotations;
1997 }
1998
1999 @Override @DefinedBy(Api.COMPILER_TREE)
2000 public List<List<JCAnnotation>> getDimAnnotations() {
2001 return dimAnnotations;
2002 }
2003 }
2004
2005 /**
2006 * A lambda expression.
2007 */
2008 public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2009
2010 public enum ParameterKind {
2011 IMPLICIT,
2012 EXPLICIT
2013 }
2014
2015 public List<JCVariableDecl> params;
2016 public JCTree body;
2017 public boolean canCompleteNormally = true;
2018 public ParameterKind paramKind;
2019 public boolean wasMethodReference;
2020
2021 public JCLambda(List<JCVariableDecl> params,
2022 JCTree body) {
2023 this.params = params;
2024 this.body = body;
2025 if (params.isEmpty() ||
2026 params.head.vartype != null) {
2027 paramKind = ParameterKind.EXPLICIT;
2028 } else {
2577
2578 @DefinedBy(Api.COMPILER_TREE)
2579 public Kind getKind() { return Kind.MEMBER_SELECT; }
2580 @DefinedBy(Api.COMPILER_TREE)
2581 public JCExpression getExpression() { return selected; }
2582 @Override @DefinedBy(Api.COMPILER_TREE)
2583 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2584 return v.visitMemberSelect(this, d);
2585 }
2586 @DefinedBy(Api.COMPILER_TREE)
2587 public Name getIdentifier() { return name; }
2588 @Override
2589 public Tag getTag() {
2590 return SELECT;
2591 }
2592 }
2593
2594 /**
2595 * Selects a member expression.
2596 */
2597 public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2598
2599 public ReferenceMode mode;
2600 public ReferenceKind kind;
2601 public Name name;
2602 public JCExpression expr;
2603 public List<JCExpression> typeargs;
2604 public Symbol sym;
2605 public Type varargsElement;
2606 public PolyKind refPolyKind;
2607 public boolean ownerAccessible;
2608 private OverloadKind overloadKind;
2609 public Type referentType;
2610
2611 public enum OverloadKind {
2612 OVERLOADED,
2613 UNOVERLOADED,
2614 ERROR
2615 }
2616
2617 /**
|
783 /**
784 * A poly expression can only be truly 'poly' in certain contexts
785 */
786 public enum PolyKind {
787 /** poly expression to be treated as a standalone expression */
788 STANDALONE,
789 /** true poly expression */
790 POLY
791 }
792
793 /** is this poly expression a 'true' poly expression? */
794 public PolyKind polyKind;
795
796 @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
797 @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
798 }
799
800 /**
801 * Common supertype for all functional expression trees (lambda and method references)
802 */
803 public abstract static sealed class JCFunctionalExpression extends JCPolyExpression
804 permits JCLambda, JCMemberReference {
805
806 public JCFunctionalExpression() {
807 //a functional expression is always a 'true' poly
808 polyKind = PolyKind.POLY;
809 }
810
811 /** list of target types inferred for this functional expression. */
812 public Type target;
813 /** The owner of this functional expression. */
814 public Symbol owner;
815 /** code reflection specific metadata. */
816 public MethodSymbol codeModel;
817
818 public Type getDescriptorType(Types types) {
819 if (target == null) {
820 return types.createErrorType(null);
821 } else if (target.hasTag(TypeTag.METHOD)) {
822 // this is a quoted expression
823 return target;
824 } else {
825 return types.findDescriptorType(target);
826 }
827 }
828 }
829
830 /**
831 * A class definition.
832 */
833 public static class JCClassDecl extends JCStatement implements ClassTree {
834 /** the modifiers */
835 public JCModifiers mods;
836 /** the name of the class */
837 public Name name;
838 /** formal class parameters */
839 public List<JCTypeParameter> typarams;
840 /** the classes this class extends */
841 public JCExpression extending;
842 /** the interfaces implemented by this class */
843 public List<JCExpression> implementing;
844 /** the subclasses allowed to extend this class, if sealed */
845 public List<JCExpression> permitting;
846 /** all variables and methods defined in this class */
1998 }
1999 @Override
2000 public Tag getTag() {
2001 return NEWARRAY;
2002 }
2003
2004 @Override @DefinedBy(Api.COMPILER_TREE)
2005 public List<JCAnnotation> getAnnotations() {
2006 return annotations;
2007 }
2008
2009 @Override @DefinedBy(Api.COMPILER_TREE)
2010 public List<List<JCAnnotation>> getDimAnnotations() {
2011 return dimAnnotations;
2012 }
2013 }
2014
2015 /**
2016 * A lambda expression.
2017 */
2018 public static final class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2019
2020 public enum ParameterKind {
2021 IMPLICIT,
2022 EXPLICIT
2023 }
2024
2025 public List<JCVariableDecl> params;
2026 public JCTree body;
2027 public boolean canCompleteNormally = true;
2028 public ParameterKind paramKind;
2029 public boolean wasMethodReference;
2030
2031 public JCLambda(List<JCVariableDecl> params,
2032 JCTree body) {
2033 this.params = params;
2034 this.body = body;
2035 if (params.isEmpty() ||
2036 params.head.vartype != null) {
2037 paramKind = ParameterKind.EXPLICIT;
2038 } else {
2587
2588 @DefinedBy(Api.COMPILER_TREE)
2589 public Kind getKind() { return Kind.MEMBER_SELECT; }
2590 @DefinedBy(Api.COMPILER_TREE)
2591 public JCExpression getExpression() { return selected; }
2592 @Override @DefinedBy(Api.COMPILER_TREE)
2593 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2594 return v.visitMemberSelect(this, d);
2595 }
2596 @DefinedBy(Api.COMPILER_TREE)
2597 public Name getIdentifier() { return name; }
2598 @Override
2599 public Tag getTag() {
2600 return SELECT;
2601 }
2602 }
2603
2604 /**
2605 * Selects a member expression.
2606 */
2607 public static non-sealed class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2608
2609 public ReferenceMode mode;
2610 public ReferenceKind kind;
2611 public Name name;
2612 public JCExpression expr;
2613 public List<JCExpression> typeargs;
2614 public Symbol sym;
2615 public Type varargsElement;
2616 public PolyKind refPolyKind;
2617 public boolean ownerAccessible;
2618 private OverloadKind overloadKind;
2619 public Type referentType;
2620
2621 public enum OverloadKind {
2622 OVERLOADED,
2623 UNOVERLOADED,
2624 ERROR
2625 }
2626
2627 /**
|