[
https://issues.apache.org/jira/browse/GROOVY-10398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17451375#comment-17451375
]
Paul King commented on GROOVY-10398:
------------------------------------
For this sample here, it is the second false you are worried about right?
{code:java}
import org.codehaus.groovy.ast.decompiled.LazyFieldNode
import org.codehaus.groovy.ast.FieldNode
import org.codehaus.groovy.control.CompilerConfiguration
FieldNode fn1 = FieldNode.newStatic(CompilerConfiguration, 'JDK11')
println fn1.equals(fn1) // true
FieldNode fn2 = new LazyFieldNode(() -> fn1, 'JDK11')
println fn1.equals(fn2) // false
println fn2.equals(fn1) // true
println fn2.equals(fn2) // false
{code}
> LazyFieldNode never equals itself
> ---------------------------------
>
> Key: GROOVY-10398
> URL: https://issues.apache.org/jira/browse/GROOVY-10398
> Project: Groovy
> Issue Type: Bug
> Components: ast builder
> Affects Versions: 3.0.9
> Reporter: James Kleeh
> Priority: Major
>
> Assume you have a LazyFieldNode instance
> LazyFieldNode node = ...
> List nodes = [node]
> `nodes.contains(node)` -> this will return false
>
> This is because the `equals` method that `LazyFieldNode` implements compares
> the object to the delegate instead of itself so a lazy field node can never
> equal itself
--
This message was sent by Atlassian Jira
(v8.20.1#820001)