[
https://issues.apache.org/jira/browse/GROOVY-6716?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-6716.
-----------------------------
> 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)