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