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

Eric Milles commented on GROOVY-11168:
--------------------------------------

So for "Foo foo = Stub \{ ... }" there are 2 possibilities for the IDE:
 # The IDE disables the spock transform for its editor (eclipse does this) and 
so the call works out to {{MockingApi#Stub(Closure)}}, which could be enhanced 
to: {{public <T> T Stub(@ClosureParams(value=FromString,options="T") 
@DelegatesTo(type="T",strategy=Closure.DELEGATE_FIRST) Closure interactions)}} 
-- I don't see the delegate or resolve strategy setting, but I do see the 
argument passing (in GroovyRuntimeUtil#invokeClosure).
 # The IDE runs the spock transform and so the call expression is transformed 
into {{this.StubImpl("foo", Foo.class, \{ ... \})}} from {{SpecInternals}}.  If 
these methods were similarly annotated then you would get improved inferencing.

> 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
>
>
> 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