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 2021/12/20 13:48:00 UTC

[jira] [Resolved] (GROOVY-10144) Calling method on specific trait fails when on different files

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

Eric Milles resolved GROOVY-10144.
----------------------------------
    Fix Version/s: 4.0.0-rc-2
       Resolution: Fixed

> Calling method on specific trait fails when on different files
> --------------------------------------------------------------
>
>                 Key: GROOVY-10144
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10144
>             Project: Groovy
>          Issue Type: Bug
>          Components: parser-antlr4
>    Affects Versions: 3.0.7
>         Environment: macOS 10.15.7, groovy 3.0.7,  AdoptOpenJDK)(build 1.8.0_282-b08)
>            Reporter: João Nelas
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: trait, traits
>             Fix For: 4.0.0-rc-2
>
>
> When calling a method on a specific trait, via the manual conflict resolution syntax, it fails with {{The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.}}.
> T.groovy
> {code:groovy}
> trait T {
>     void exec() {
>         println("T - exec");
>     }
> }
> {code}
> A.groovy
> {code:groovy}
> class A implements T{
>     void exec() {
>         println("A - exec");
>         T.super.exec();
>     }
> }
> {code}
> diff_files.groovy
> {code:groovy}
> import A;
> new A().exec();
> {code}
> Running {{diff_files.groovy}} gives an error:
> {noformat}
> > groovy diff_files.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> file:/Users/joao/tmp/groovy_trait/A.groovy: 6: The usage of 'Class.this' and 'Class.super' is only allowed in nested/inner classes.
>  @ line 6, column 10.
>            T.super.exec();
>             ^
> 1 error
> {noformat}
> If everything is included on the same file
>  onefile.groovy
> {code:groovy}
> trait T {
>     void exec() {
>         println("T - exec");
>     }
> }
> class A implements T{
>     void exec() {
>         println("A - exec");
>         T.super.exec();
>     }
> }
> new A().exec();
> {code}
> everything works as expected:
> {noformat}
> >groovy onefile.groovy
> A - exec
> T - exec
> {noformat}



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