groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From C├ędric Champeau <cedric.champ...@gmail.com>
Subject Re: Type safety on sum()/getAt()
Date Fri, 09 Oct 2015 16:15:03 GMT
I don't think it is possible without a breaking change. Today `sum` and
`getAt` can return anything. There's no requirement that the sum of A+A is
an A, nor that A+B return type is the same as B+A, or any kind of
constraint like that. Adding this at the source level would enforce type
safety, but it would also break existing code.

2015-10-09 9:54 GMT+02:00 Peter Ledbrook <peter@cacoethes.co.uk>:

> Hi,
>
> I've noticed that @TypeChecked doesn't work so well with typed collections
> and the sum() & getAt() methods (perhaps others as well). I had a quick
> look at sum() in DefaultGroovyMethods and noticed that it doesn't use
> parameterised types, unlike inject() for example.
>
> Would there be any issues with updating sum() and getAt() to work with
> parameterised types? The current situation makes using @TypeChecked harder
> than it needs to be.
>
> Thanks,
>
> Peter
>
> --
> Peter Ledbrook
> t: @pledbrook
> w: http://www.cacoethes.co.uk/
>

Mime
View raw message