New behavior : java: incompatible types: inferred type does not conform to upper bound(s)
Boaz Nahum
boaznahum at gmail.com
Mon Jan 7 13:01:13 PST 2013
Thank.As you see it now, Is there a chance that it won't be fixed ?I'm
asking because it is stopper for us - We have too many lines like this.
Thanks
Boaz
On Jan 7, 2013 10:59 AM, "Maurizio Cimadamore" <
maurizio.cimadamore at oracle.com> wrote:
> On 01/01/13 15:34, Boaz Nahum wrote:
>
>> Hi.
>>
>> Old code is no longer compiled (I built lambda/lambda today 1-1-2013)
>>
>> static class F<T> {}
>>
>> static <T> T get(F<T> f) {return null;}
>> F<Integer> fi = new F<>();
>>
>>
>> double d1 = get(fi);
>>
>> The last line yields
>>
>> java: incompatible types: inferred type does not conform to upper bound(s)
>> inferred: java.lang.Integer
>> upper bound(s): java.lang.Double,java.lang.**Object
>>
> This is a side-effect of some inference improvements we have made; we now
> wait to see the target type before instantiating method type-parameters,
> which allows the right thing to happen in cases like:
>
> class Cell<X> {
> Cell(X x) { ... }
> }
>
> Cell<Number> c = new Cell<>(1); //fails with JDK 7
>
> I think your example shows there're still some improvements to be made
> around handling of primitives
>
> Maurizio
>
>>
>> Only casting solve the problem:
>>
>> double d1 = (int)get(fi);
>> double d1 = (double)get(fi);
>>
>>
>> Happy new year
>> Boaz
>>
>>
>
More information about the lambda-dev
mailing list