On 22/03/2013, at 12:07 AM, Adam Murdoch <adam.murd...@gradleware.com> wrote:

> 
> 
> 
> On 22 March 2013 09:09, Luke Daley <luke.da...@gradleware.com> wrote:
> Hi,
> 
> DomainObjectCollection<T> {
>         <S extends T> DomainObjectCollection<S> withType(Class<S>) {}
> }
> 
> This generic signature is not right. It doesn't allow creating a filtered set 
> by an interface. My use case was…
> 
> tasks.withType(JavaForkOptions) {
> 
> }
> 
> But this doesn't work.
> 
> Do we want to fix this? If so, how the hell do we do so in a backwards 
> compatible way?
> 
> We can just remove the `extends T` bound on `S`. It's source and binary 
> backwards-compatible.

It's not quite that easy unfortunately, as sub classes specialise these methods 
to strongly type the returned container type which demands the argument be a 
subtype of the element type:

https://github.com/gradle/gradle/blob/master/subprojects/core/src/main/groovy/org/gradle/api/tasks/TaskCollection.java#L55

-- 
Luke Daley
Principal Engineer, Gradleware 
http://gradleware.com

Join me at the Gradle Summit 2013, June 13th and 14th in Santa Clara, CA: 
http://www.gradlesummit.com


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to