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

ASF GitHub Bot commented on GROOVY-12475:
-----------------------------------------

paulk-asert commented on PR #3018:
URL: https://github.com/apache/groovy/pull/3018#issuecomment-6388823505

   Thanks Daniel.
   
   3. The two checks are on different paths. AstBuilder only merges a split 
property when one half has a visibility modifier, and there Object is still an 
unresolved name, hence the helper. With @PackageScope neither half has a 
modifier, so both parse as properties and the parser doesn't compare them. 
PackageScopeASTTransformation runs in SEMANTIC_ANALYSIS, after resolution, when 
def/var/val and Object are all java.lang.Object, so ClassNode.equals already 
treats them as equal. The @PackageScope cases in testDefAndObjectAreTheSameType 
exercise that path.
   
   4. Not just defensive: each property declaration creates its own field, so 
the class has two fields of that name by the time the transform runs. 
removeField(name) removes only the one held in the field index; removeIf takes 
the other (that leftover is the duplicate-field class from the GROOVY-11159 
regression). I'll expand the comment to say so.




> split property definition and PackageScope transform
> ----------------------------------------------------
>
>                 Key: GROOVY-12475
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12475
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 4.0.33, 5.1.3, 6.0.0
>            Reporter: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class C {
>   def foo = 'bar'
>   @groovy.transform.PackageScope Object foo
> }
> println new C().foo
> println new C().@foo
> println new C().getFoo()
> {code}
> Fails with "The field 'foo' is declared multiple times."  And if I move "= 
> 'bar'" to the field, I instead get "The split property definition named 'foo' 
> must not have an initial value for both the field and the property."



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to