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

Paul King commented on GROOVY-10515:
------------------------------------

Actually, the code generated is almost the same for 2.4 and 2.5. I.e. both 
never use {{level0field}} directly in the {{Level1}} class. We just never 
bothered checking for the "unused" {{level0field}} name before but we have 
stricter checking and do this now. This lets you fix your bug. While that field 
is never used directly, it is accounted for in your {{equals}} and {{hashCode}} 
methods by virtue of the {{callSuper}} annotation attribute.

There is an {{includeSuperFields}} annotation attribute in {{MapConstructor}}, 
{{TupleConstrutor}} and {{ToString}}.

> EqualsAndHashCode no longer access parent class
> -----------------------------------------------
>
>                 Key: GROOVY-10515
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10515
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: David Brown
>            Priority: Minor
>
> It appears there is a breaking change between Groovy 2.4 and 2.5 to the 
> EqualsAndHashCode() method.   In 2.4, the includes attribute could reference 
> properties of parent classes up the inheritance tree, however, in 2.5 an 
> exception is thrown indicating the inherited field(s) do not exist. 
> The following code demonstrates a simple inheritance relationship with 
> reproducible exception that works correctly with Groovy 2.4.x 
> {code:java}
> import groovy.transform.EqualsAndHashCode
> @EqualsAndHashCode(includes = ['level0field'], includeFields = true)
> abstract class Level0 {
>   public String level0field
> }
> @EqualsAndHashCode(includes = ['level0field', 'level1field'], callSuper = 
> true, includeFields = true)
> class Level1 extends Level0 {
>   String level1field
> }
>  {code}



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

Reply via email to