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

Björn Kautler commented on GROOVY-11168:
----------------------------------------

I tried it for testing purposes with
{{protected <T> T MockImpl(String inferredName, Class<T> inferredType, 
@DelegatesTo(strategy = Closure.DELEGATE_FIRST, type = "T") 
@ClosureParams(SecondParam.FirstGenericType.class) Closure<?> closure) {}}
and
{{protected <T> T MockImpl(String inferredName, @DelegatesTo.Target Class<T> 
inferredType, @DelegatesTo(strategy = Closure.DELEGATE_FIRST, genericTypeIndex 
= 0) @ClosureParams(SecondParam.FirstGenericType.class) Closure<?> closure) {}}
with {{@TypeChecked}}.
The {{@ClosureParams}} works fine, while neither of the {{@DelegatesTo}} has 
any effect.
And I'm not talking about the IDE here, but just about Groovy's 
{{@TypeChecked}} during compilation.
That the place is the correct one to look at (afaict) can be seen by the 
{{@ClosureParams}} that is actually considered.


> Ability to `@DelegatesTo` the return type
> -----------------------------------------
>
>                 Key: GROOVY-11168
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11168
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Björn Kautler
>            Assignee: Eric Milles
>            Priority: Major
>         Attachments: screenshot-1.png, screenshot-2.png
>
>
> With a method
> {code:java}
> public <T> T Stub(Closure interactions); {code}
> that is then used like
> {code:java}
> Foo foo = Stub { /* configure the foo here */ } {code}
> I'd like to be able to specify that the delegate is of type {{T}} so in the 
> given example of type {{{}Foo{}}}.
> Currently we do this in Spock via IDE-specific gdsl/dsld Scripts.
> But it would be nice if this would be supported out of the box.
> (Ideally in 2.5 already, as we still have a 2.5 compatible artifact. :))



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to