Steinar Haugen created GROOVY-7714:
--------------------------------------
Summary: Trait with static generic method and usage in different
sub-project
Key: GROOVY-7714
URL: https://issues.apache.org/jira/browse/GROOVY-7714
Project: Groovy
Issue Type: Bug
Affects Versions: 2.4.5
Reporter: Steinar Haugen
Bumped into a compilation error and created a minimal project to reproduce.
It consists of a gradle project with two subprojects. The first subproject
contains a trait and an implementing class. The second subproject contains a
class that returns the implemening class.
See attached zip file for source code.
It consists of three source files:
{code:title=sub1/src/main/groovy/sub1/MyTrait.groovy}
package sub1
trait MyTrait {
static <T extends MyTrait> T getMyTrait() {null}
}
{code}
{code:title=sub1/src/main/groovy/sub1/MyTraitImpl.groovy}
package sub1
class MyTraitImpl implements MyTrait {
}
{code}
{code:title=sub1/src/main/groovy/sub1/Producer.groovy}
package sub2
import sub1.MyTraitImpl
class Producer {
MyTraitImpl produce() {
return null
}
}
{code}
Building yields the following error message:
Execution failed for task ':sub2:compileGroovy'.
> BUG! exception in phase 'class generation' in source unit
> '/source/trait-bug/sub2/src/main/groovy/sub2/Producer.groovy' Type is null.
> Most probably you let a transform reuse existing ClassNodes with generics
> information, that is now used in a wrong context.
If the source code in sub2 is moved to sub1, it compiles without error.
If the method signature is changed to "MyTrait getMyTrait()" it compiles
without error.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)