[ https://issues.apache.org/jira/browse/GROOVY-11508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17892803#comment-17892803 ]
ASF GitHub Bot commented on GROOVY-11508: ----------------------------------------- jamesfredley opened a new pull request, #2117: URL: https://github.com/apache/groovy/pull/2117 https://issues.apache.org/jira/browse/GROOVY-11508 This PR converts the `RuntimeParserException`, which stops compilation, to a more detailed warning about using a `Trait` or `Interface` with more than one generic type parameter via inheritance. Resolves https://github.com/grails/grails-data-mapping/issues/1811 which is a significant open issue for the Groovy 3.0.x to 4.0.x upgrade in preparation for Grails 7. Grails 6 and lower were still on Groovy 3.0.x. Precise simplified example of the code which results in the exception with Groovy 4.0.x compiler: https://github.com/grails/grails-data-mapping/issues/1811#issue-2481317054 https://github.com/grails/grails-data-mapping/issues/1811#issuecomment-2419515195 - the decompiled Grails Domain Classes, compiled with Groovy 4.0.23, after changing the exception to a warning. These Grails Domains, with inheritance, compile and run without issue once the exception is removed during pre-compilation verification. In each instance the `Trait` or `Interface` which is implemented with 2+ generic types via inheritance, have generic types which are compatible and extend in a lineage hierarchy. The Groovy 4 compiler only copies the lowest level Trait or Interface methods into the class, before compiling, which was the approach in Groovy 3 and same and expected approach in Groovy 4. Example output after restoring Domain Inheritance and Inheritance tests on https://github.com/grails/grails-data-mapping/ ``` > Task :grails-datastore-gorm-tck:compileGroovy Warning: on grails.gorm.tests.City the interface GormEntity was implemented more than once with different arguments: org.grails.datastore.gorm.GormEntity<grails.gorm.tests.City> and org.grails.datastore.gorm.GormEntity<grails.gorm.tests.Location>, grails.gorm.tests.City will only implement the lowest level GormEntity Warning: on grails.gorm.tests.City the interface GormEntityApi was implemented more than once with different arguments: org.grails.datastore.gorm.GormEntityApi<grails.gorm.tests.City> and org.grails.datastore.gorm.GormEntityApi<grails.gorm.tests.Location>, grails.gorm.tests.City will only implement the lowest level GormEntityApi Warning: on grails.gorm.tests.City the interface Entity was implemented more than once with different arguments: grails.gorm.Entity<grails.gorm.tests.City> and grails.gorm.Entity<grails.gorm.tests.Location>, grails.gorm.tests.City will only implement the lowest level Entity Warning: on grails.gorm.tests.Country the interface GormEntity was implemented more than once with different arguments: org.grails.datastore.gorm.GormEntity<grails.gorm.tests.Country> and org.grails.datastore.gorm.GormEntity<grails.gorm.tests.Location>, grails.gorm.tests.Country will only implement the lowest level GormEntity Warning: on grails.gorm.tests.Country the interface GormEntityApi was implemented more than once with different arguments: org.grails.datastore.gorm.GormEntityApi<grails.gorm.tests.Country> and org.grails.datastore.gorm.GormEntityApi<grails.gorm.tests.Location>, grails.gorm.tests.Country will only implement the lowest level GormEntityApi Warning: on grails.gorm.tests.Country the interface Entity was implemented more than once with different arguments: grails.gorm.Entity<grails.gorm.tests.Country> and grails.gorm.Entity<grails.gorm.tests.Location>, grails.gorm.tests.Country will only implement the lowest level Entity ``` > Multiple traits with related generic types cannot be used > --------------------------------------------------------- > > Key: GROOVY-11508 > URL: https://issues.apache.org/jira/browse/GROOVY-11508 > Project: Groovy > Issue Type: Bug > Components: Compiler > Affects Versions: 4.0.0 > Reporter: James Daugherty > Assignee: Eric Milles > Priority: Major > Attachments: screenshot-1.png, screenshot-2.png, screenshot-3.png > > > When updating Grails from Groovy 3.x to 4.x we discovered that GROOVY-5106 > prevents us from updating to Groovy 4 for the > [grails-data-mapping|https://github.com/grails/grails-data-mapping] (GORM) > project. Groovy-5106 does not take into account relationships between > generic types and groovy does not support inheritance in generic types on > traits so we have no workable solution for using Groovy 4. > > For example, the following is not possible in Groovy 4: > {code:java} > class Parent extends GormEntity<Parent> { > } > class Child extends GormEntity<Child> { > } > class GormEntity<? extends GormEntity> { // ? extends GormEntity is not > allowed > }{code} > > We have documented the impacts of this issue on the grails-data-mapping > project here: [https://github.com/grails/grails-data-mapping/issues/1811] > We have discovered that the original change could be reverted and continue to > work with the latest Java & Groovy. > > For Grails Data Mapping (GORM), there is support for inheritance between a > Parent & Child domain object. This is often implemented like this: > {code:java} > class Parent extends GormEntity<Parent> { > } > class Child extends GormEntity<Child> { > } > trait GormEntity<D> { // Simplified for this ticket > static D get(Serializable id) > > static List<D> getAll() > } > {code} > This allows someone to do the following in code: > {code:java} > Parent.get(1L) // Will find either a Child or Parent > Child.get(1L) // Will find only child types{code} > > Since Groovy-5106 does not take into account inheritance, can this change be > reverted or changed to a warning until inheritance is taken into account? -- This message was sent by Atlassian Jira (v8.20.10#820010)