You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/02/20 22:04:00 UTC

[jira] [Commented] (GROOVY-9414) Groovy 3.0.1 : @Delegate does not work with default getter

    [ https://issues.apache.org/jira/browse/GROOVY-9414?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17041318#comment-17041318 ] 

Paul King commented on GROOVY-9414:
-----------------------------------

Right, so it works if you use "name" but then delegates to both "getName" and "setName" which you in general may not want.
And in 2.5.9 it works as above or by excluding "setName".

> Groovy 3.0.1 : @Delegate does not work with default getter
> ----------------------------------------------------------
>
>                 Key: GROOVY-9414
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9414
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 3.0.1
>         Environment: macOS Catalina
> Version: 10.15.3
>            Reporter: Puneet Behl
>            Priority: Major
>
> It looks like the default getter for a property is not picked up by the @{{Delegate}}. For example the below code:
> {code:groovy}
> interface Foo {
>     String getName()
> }
> class Bar {
>     String name
> }
> class FooImpl implements Foo {
>     @Delegate(includes = "getName") Bar bar
> }
> {code}
> throws a compile-time error as:
> {code:java}
> 1 compilation error:
> Error during @Delegate processing: 'includes' property or method 'getName' does not exist.
>  at line: 10, column: 5
> {code}
> *Please note* that I have also tested with the latest 3.0.2-SNAPSHOT.



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