You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/08/18 19:37:00 UTC

[jira] [Assigned] (GROOVY-8000) Problem With Trait Generics

     [ https://issues.apache.org/jira/browse/GROOVY-8000?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles reassigned GROOVY-8000:
-----------------------------------

    Assignee: Eric Milles

> Problem With Trait Generics
> ---------------------------
>
>                 Key: GROOVY-8000
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8000
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>            Reporter: Jeff Scott Brown
>            Assignee: Eric Milles
>            Priority: Major
>
> The project at https://github.com/jeffbrown/generictraits contains the following:
> {code:title=src/main/groovy/demo/TopTrait.groovy|borderStyle=solid}
> package demo
> trait TopTrait<T> {
>     T getSomething() {}
> }
> {code}
> {code:title=src/main/groovy/demo/MiddleTrait.groovy|borderStyle=solid}
> package demo
> trait MiddleTrait<T> implements TopTrait<T> {}
> {code}
> {code:title=src/main/groovy/demo/BottomTrait.groovy|borderStyle=solid}
> package demo
> trait BottomTrait<T> implements MiddleTrait<T> {}
> {code}
> {code:title=src/main/groovy/demo/Demo.groovy|borderStyle=solid}
> package demo
> // if this class implements MiddleTrait instead
> // of BottomTrait, it will compile...
> class Demo implements BottomTrait<String> {}
> {code}
> {noformat}
>  $ ./gradlew clean cG
> :clean
> :compileJava UP-TO-DATE
> :compileGroovy
> startup failed:
> /Users/jeff/t/generictraits/src/main/groovy/demo/Demo.groovy: -1: The return type of java.lang.Object getSomething() in demo.Demo is incompatible with java.lang.String in demo.TopTrait
> . At [-1:-1]  @ line -1, column -1.
> 1 error
> :compileGroovy FAILED
> FAILURE: Build failed with an exception.
> * What went wrong:
> Execution failed for task ':compileGroovy'.
> > Compilation failed; see the compiler error output for details.
> * Try:
> Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
> BUILD FAILED
> Total time: 2.123 secs
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)