You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2021/12/29 12:36:00 UTC

[jira] [Commented] (GROOVY-10434) ClassNode isRecord and isSealed not useful before AST transformation

    [ https://issues.apache.org/jira/browse/GROOVY-10434?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17466442#comment-17466442 ] 

Paul King commented on GROOVY-10434:
------------------------------------

Definitely the documentation should be expanded.

We do have other methods which are impacted by AST transforms, e.g. {{MethodNode#isPublic}} might change (and hence doesn't work _correctly_ in earlier phases) when processing {{{}@PackageScope{}}}.

Having said that, there are counter examples where we've moved such methods to other classes like {{{}Traits#isTrait{}}}.

In this case however, you'd typically call {{isRecord}} just before calling {{getRecordComponents}} and {{isSealed}} just before calling {{getPermittedSubclasses}}, it seems a little weird that you'd want that functionality split across {{ClassNode}} and {{ClassNodeUtils}}.

> ClassNode isRecord and isSealed not useful before AST transformation
> --------------------------------------------------------------------
>
>                 Key: GROOVY-10434
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10434
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 4.0.0-rc-2
>            Reporter: Eric Milles
>            Priority: Major
>
> The new to Groovy 4 methods {{ClassNode#isRecord}} and {{ClassNode#isSealed}} do not work for a node that has not yet been processed by the record/sealed transform or in some cases {{ResolveVisitor}}.  And they do not work for a node that is a reference to a record or sealed type.
> For these reasons, I request that the methods be moved to {{ClassNodeUtils}} with some extra notes or made private within classgen somewhere.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)