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;
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 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 {
2586
2587 @DefinedBy(Api.COMPILER_TREE)
2588 public Kind getKind() { return Kind.MEMBER_SELECT; }
2589 @DefinedBy(Api.COMPILER_TREE)
2590 public JCExpression getExpression() { return selected; }
2591 @Override @DefinedBy(Api.COMPILER_TREE)
2592 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2593 return v.visitMemberSelect(this, d);
2594 }
2595 @DefinedBy(Api.COMPILER_TREE)
2596 public Name getIdentifier() { return name; }
2597 @Override
2598 public Tag getTag() {
2599 return SELECT;
2600 }
2601 }
2602
2603 /**
2604 * Selects a member expression.
2605 */
2606 public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2607
2608 public ReferenceMode mode;
2609 public ReferenceKind kind;
2610 public Name name;
2611 public JCExpression expr;
2612 public List<JCExpression> typeargs;
2613 public Symbol sym;
2614 public Type varargsElement;
2615 public PolyKind refPolyKind;
2616 public boolean ownerAccessible;
2617 private OverloadKind overloadKind;
2618 public Type referentType;
2619
2620 public enum OverloadKind {
2621 OVERLOADED,
2622 UNOVERLOADED,
2623 ERROR
2624 }
2625
2626 /**
|
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 return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
820 }
821 }
822
823 /**
824 * A class definition.
825 */
826 public static class JCClassDecl extends JCStatement implements ClassTree {
827 /** the modifiers */
828 public JCModifiers mods;
829 /** the name of the class */
830 public Name name;
831 /** formal class parameters */
832 public List<JCTypeParameter> typarams;
833 /** the classes this class extends */
834 public JCExpression extending;
835 /** the interfaces implemented by this class */
836 public List<JCExpression> implementing;
2000 }
2001 @Override
2002 public Tag getTag() {
2003 return NEWARRAY;
2004 }
2005
2006 @Override @DefinedBy(Api.COMPILER_TREE)
2007 public List<JCAnnotation> getAnnotations() {
2008 return annotations;
2009 }
2010
2011 @Override @DefinedBy(Api.COMPILER_TREE)
2012 public List<List<JCAnnotation>> getDimAnnotations() {
2013 return dimAnnotations;
2014 }
2015 }
2016
2017 /**
2018 * A lambda expression.
2019 */
2020 public static final class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2021
2022 public enum ParameterKind {
2023 IMPLICIT,
2024 EXPLICIT
2025 }
2026
2027 public List<JCVariableDecl> params;
2028 public JCTree body;
2029 public boolean canCompleteNormally = true;
2030 public ParameterKind paramKind;
2031 public boolean wasMethodReference;
2032
2033 public JCLambda(List<JCVariableDecl> params,
2034 JCTree body) {
2035 this.params = params;
2036 this.body = body;
2037 if (params.isEmpty() ||
2038 params.head.vartype != null) {
2039 paramKind = ParameterKind.EXPLICIT;
2040 } else {
2589
2590 @DefinedBy(Api.COMPILER_TREE)
2591 public Kind getKind() { return Kind.MEMBER_SELECT; }
2592 @DefinedBy(Api.COMPILER_TREE)
2593 public JCExpression getExpression() { return selected; }
2594 @Override @DefinedBy(Api.COMPILER_TREE)
2595 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2596 return v.visitMemberSelect(this, d);
2597 }
2598 @DefinedBy(Api.COMPILER_TREE)
2599 public Name getIdentifier() { return name; }
2600 @Override
2601 public Tag getTag() {
2602 return SELECT;
2603 }
2604 }
2605
2606 /**
2607 * Selects a member expression.
2608 */
2609 public static non-sealed class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2610
2611 public ReferenceMode mode;
2612 public ReferenceKind kind;
2613 public Name name;
2614 public JCExpression expr;
2615 public List<JCExpression> typeargs;
2616 public Symbol sym;
2617 public Type varargsElement;
2618 public PolyKind refPolyKind;
2619 public boolean ownerAccessible;
2620 private OverloadKind overloadKind;
2621 public Type referentType;
2622
2623 public enum OverloadKind {
2624 OVERLOADED,
2625 UNOVERLOADED,
2626 ERROR
2627 }
2628
2629 /**
|