groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (GROOVY-6716) Cannot implement a trait via anonymous class
Date Mon, 06 Aug 2018 13:53:00 GMT

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

Paul King resolved GROOVY-6716.
-------------------------------
       Resolution: Fixed
         Assignee: Paul King
    Fix Version/s: 2.5.2

Fixed.

> Cannot implement a trait via anonymous class
> --------------------------------------------
>
>                 Key: GROOVY-6716
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6716
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Compiler
>    Affects Versions: 2.3.0-beta-2
>            Reporter: Dinko Srkoc
>            Assignee: Paul King
>            Priority: Major
>              Labels: traits
>             Fix For: 2.5.2
>
>
> It is currently not possible to implement a trait by using anonymous classes:
> {code}
> trait Foo { def foo() { 42 } }
> new Foo() {} // compiler complains
> {code}
> The compiler message is:
> {{You are not allowed to extend the interface 'Foo', use implements instead}}
> This is not consistent with interfaces and abstract classes:
> {code}
> interface Foo { def foo() }
> new Foo() { def foo() { 42 } } // this works
> {code}
> It would be nice, for consistency reasons if no other, if traits could be extended to
support this feature.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message