Skip to content

@Trait applied to interface with generic cause compile error #733

@AntonPanikov

Description

@AntonPanikov

I found one more bug related to Grails projects, but I do not think it is Grails related, but @trait annotation related. I was unable to extract and isolate this issue in the pure groovy project.

I am using:
Eclipse Oxygen.3a Release (4.7.3a)
Groovy-Eclipse 3.1.0.xx-201809251603-e47

It is easy to reproduce with SDKMAN:

Install sdkman:
curl -s "https://get.sdkman.io" | bash
Source or open new shell:
source "$HOME/.sdkman/bin/sdkman-init.sh"
Install grails:
sdk i grails
Create sample app in some folder (grails-example):
grails create-app --profile web --inplace
Create sample service:
grails create-service sample

Import this project into eclipse and add Gradle nature. Edit grails-sample/grails-app/services/grails/sample/SampleService.groovy, like this:

package grails.sample

import grails.events.Events
import grails.gorm.transactions.Transactional

@Transactional
class SampleService implements Events {
}

Copy this service as SampleService2 and just add reference to the previous one:

package grails.sample

import grails.gorm.transactions.Transactional

@Transactional
class SampleService2 {
    SampleService sampleService
}

The second one will start complain about:

Inconsistent classfile encountered: The undefined type parameter T is referenced from within SampleService

I believe it is T generic from Event interface, but I can not reproduce it in pure groovy.

Same complain from generated UnitTest class. Sometime this error is gone, but as soon as I clean or edit the source, just adding and removing space character for example, it will come back.

I am attaching my sample app zip here, just in case.
grails-sample.zip

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions