795 /**
796 * A poly expression can only be truly 'poly' in certain contexts
797 */
798 public enum PolyKind {
799 /** poly expression to be treated as a standalone expression */
800 STANDALONE,
801 /** true poly expression */
802 POLY
803 }
804
805 /** is this poly expression a 'true' poly expression? */
806 public PolyKind polyKind;
807
808 @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
809 @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
810 }
811
812 /**
813 * Common supertype for all functional expression trees (lambda and method references)
814 */
815 public abstract static class JCFunctionalExpression extends JCPolyExpression {
816
817 public JCFunctionalExpression() {
818 //a functional expression is always a 'true' poly
819 polyKind = PolyKind.POLY;
820 }
821
822 /** list of target types inferred for this functional expression. */
823 public Type target;
824 /** The owner of this functional expression. */
825 public Symbol owner;
826
827 public Type getDescriptorType(Types types) {
828 return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
829 }
830 }
831
832 /**
833 * A class definition.
834 */
835 public static class JCClassDecl extends JCStatement implements ClassTree {
836 /** the modifiers */
837 public JCModifiers mods;
838 /** the name of the class */
839 public Name name;
840 /** formal class parameters */
841 public List<JCTypeParameter> typarams;
842 /** the classes this class extends */
843 public JCExpression extending;
844 /** the interfaces implemented by this class */
845 public List<JCExpression> implementing;
846 /** the subclasses allowed to extend this class, if sealed */
847 public List<JCExpression> permitting;
848 /** all variables and methods defined in this class */
849 public List<JCTree> defs;
2013 }
2014 @Override
2015 public Tag getTag() {
2016 return NEWARRAY;
2017 }
2018
2019 @Override @DefinedBy(Api.COMPILER_TREE)
2020 public List<JCAnnotation> getAnnotations() {
2021 return annotations;
2022 }
2023
2024 @Override @DefinedBy(Api.COMPILER_TREE)
2025 public List<List<JCAnnotation>> getDimAnnotations() {
2026 return dimAnnotations;
2027 }
2028 }
2029
2030 /**
2031 * A lambda expression.
2032 */
2033 public static class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2034
2035 public enum ParameterKind {
2036 IMPLICIT,
2037 EXPLICIT
2038 }
2039
2040 public List<JCVariableDecl> params;
2041 public JCTree body;
2042 public boolean canCompleteNormally = true;
2043 public ParameterKind paramKind;
2044 public boolean wasMethodReference;
2045
2046 public JCLambda(List<JCVariableDecl> params,
2047 JCTree body) {
2048 this.params = params;
2049 this.body = body;
2050 if (params.isEmpty() ||
2051 !params.head.isImplicitlyTyped()) {
2052 paramKind = ParameterKind.EXPLICIT;
2053 } else {
2602
2603 @DefinedBy(Api.COMPILER_TREE)
2604 public Kind getKind() { return Kind.MEMBER_SELECT; }
2605 @DefinedBy(Api.COMPILER_TREE)
2606 public JCExpression getExpression() { return selected; }
2607 @Override @DefinedBy(Api.COMPILER_TREE)
2608 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2609 return v.visitMemberSelect(this, d);
2610 }
2611 @DefinedBy(Api.COMPILER_TREE)
2612 public Name getIdentifier() { return name; }
2613 @Override
2614 public Tag getTag() {
2615 return SELECT;
2616 }
2617 }
2618
2619 /**
2620 * Selects a member expression.
2621 */
2622 public static class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2623
2624 public ReferenceMode mode;
2625 public ReferenceKind kind;
2626 public Name name;
2627 public JCExpression expr;
2628 public List<JCExpression> typeargs;
2629 public Symbol sym;
2630 public Type varargsElement;
2631 public PolyKind refPolyKind;
2632 public boolean ownerAccessible;
2633 private OverloadKind overloadKind;
2634 public Type referentType;
2635
2636 public enum OverloadKind {
2637 OVERLOADED,
2638 UNOVERLOADED,
2639 ERROR
2640 }
2641
2642 /**
|
795 /**
796 * A poly expression can only be truly 'poly' in certain contexts
797 */
798 public enum PolyKind {
799 /** poly expression to be treated as a standalone expression */
800 STANDALONE,
801 /** true poly expression */
802 POLY
803 }
804
805 /** is this poly expression a 'true' poly expression? */
806 public PolyKind polyKind;
807
808 @Override public boolean isPoly() { return polyKind == PolyKind.POLY; }
809 @Override public boolean isStandalone() { return polyKind == PolyKind.STANDALONE; }
810 }
811
812 /**
813 * Common supertype for all functional expression trees (lambda and method references)
814 */
815 public abstract static sealed class JCFunctionalExpression extends JCPolyExpression
816 permits JCLambda, JCMemberReference {
817
818 public JCFunctionalExpression() {
819 //a functional expression is always a 'true' poly
820 polyKind = PolyKind.POLY;
821 }
822
823 /** list of target types inferred for this functional expression. */
824 public Type target;
825 /** The owner of this functional expression. */
826 public Symbol owner;
827 /** code reflection specific metadata. */
828 public CodeReflectionInfo codeReflectionInfo;
829
830 public Type getDescriptorType(Types types) {
831 return target != null ? types.findDescriptorType(target) : types.createErrorType(null);
832 }
833
834 public record CodeReflectionInfo(MethodSymbol codeModel, Type reflectableLambdaMetafactory) { }
835 }
836
837 /**
838 * A class definition.
839 */
840 public static class JCClassDecl extends JCStatement implements ClassTree {
841 /** the modifiers */
842 public JCModifiers mods;
843 /** the name of the class */
844 public Name name;
845 /** formal class parameters */
846 public List<JCTypeParameter> typarams;
847 /** the classes this class extends */
848 public JCExpression extending;
849 /** the interfaces implemented by this class */
850 public List<JCExpression> implementing;
851 /** the subclasses allowed to extend this class, if sealed */
852 public List<JCExpression> permitting;
853 /** all variables and methods defined in this class */
854 public List<JCTree> defs;
2018 }
2019 @Override
2020 public Tag getTag() {
2021 return NEWARRAY;
2022 }
2023
2024 @Override @DefinedBy(Api.COMPILER_TREE)
2025 public List<JCAnnotation> getAnnotations() {
2026 return annotations;
2027 }
2028
2029 @Override @DefinedBy(Api.COMPILER_TREE)
2030 public List<List<JCAnnotation>> getDimAnnotations() {
2031 return dimAnnotations;
2032 }
2033 }
2034
2035 /**
2036 * A lambda expression.
2037 */
2038 public static final class JCLambda extends JCFunctionalExpression implements LambdaExpressionTree {
2039
2040 public enum ParameterKind {
2041 IMPLICIT,
2042 EXPLICIT
2043 }
2044
2045 public List<JCVariableDecl> params;
2046 public JCTree body;
2047 public boolean canCompleteNormally = true;
2048 public ParameterKind paramKind;
2049 public boolean wasMethodReference;
2050
2051 public JCLambda(List<JCVariableDecl> params,
2052 JCTree body) {
2053 this.params = params;
2054 this.body = body;
2055 if (params.isEmpty() ||
2056 !params.head.isImplicitlyTyped()) {
2057 paramKind = ParameterKind.EXPLICIT;
2058 } else {
2607
2608 @DefinedBy(Api.COMPILER_TREE)
2609 public Kind getKind() { return Kind.MEMBER_SELECT; }
2610 @DefinedBy(Api.COMPILER_TREE)
2611 public JCExpression getExpression() { return selected; }
2612 @Override @DefinedBy(Api.COMPILER_TREE)
2613 public <R,D> R accept(TreeVisitor<R,D> v, D d) {
2614 return v.visitMemberSelect(this, d);
2615 }
2616 @DefinedBy(Api.COMPILER_TREE)
2617 public Name getIdentifier() { return name; }
2618 @Override
2619 public Tag getTag() {
2620 return SELECT;
2621 }
2622 }
2623
2624 /**
2625 * Selects a member expression.
2626 */
2627 public static non-sealed class JCMemberReference extends JCFunctionalExpression implements MemberReferenceTree {
2628
2629 public ReferenceMode mode;
2630 public ReferenceKind kind;
2631 public Name name;
2632 public JCExpression expr;
2633 public List<JCExpression> typeargs;
2634 public Symbol sym;
2635 public Type varargsElement;
2636 public PolyKind refPolyKind;
2637 public boolean ownerAccessible;
2638 private OverloadKind overloadKind;
2639 public Type referentType;
2640
2641 public enum OverloadKind {
2642 OVERLOADED,
2643 UNOVERLOADED,
2644 ERROR
2645 }
2646
2647 /**
|