Can't make simple Streams over indirect projects work
Srikanth
srikanth.adayapalam at oracle.com
Wed Aug 14 10:48:46 UTC 2019
On 14/08/19 2:21 PM, Srikanth wrote:
[...]
> I believe the code snippet above compiles fine after this push:
> http://hg.openjdk.java.net/valhalla/valhalla/rev/7ec951ef532d
>
> while the one below still fails to compile. I am looking into whether
> that is reasonable behavior or not.
With the push
http://hg.openjdk.java.net/valhalla/valhalla/rev/332773949385 for
https://bugs.openjdk.java.net/browse/JDK-8229700, the code snippet below
compiles too.
Thanks for the report and continued testing/experimenting with Valhalla.
Srikanth
>
> I hope this unblocks you enough to continue your experiments.
>
> Much appreciate the defect reports and your continued testing.
>
> Thanks!
> Srikanth
>> whereas the type-inferred form:
>>
>> Stream<OptionalInt?> soi = opts.stream();
>> ToIntFunction<OptionalInt?> f = o -> {
>> if (o == null) return 0;
>> OptionalInt op = (OptionalInt)o;
>> return op.orElse(0);
>> };
>> IntStream sint = soi.mapToInt(f);
>> int total = sint.reduce(0, (x, y) -> x + y);
>>
>> fails with this:
>>
>> bevans$ javac -XDallowWithFieldOperator -XDallowGenericsOverValues
>> javamag/Main4.java
>> javamag/Main4.java:19: error: incomparable types: OptionalInt and <null>
>> if (o == null) return 0;
>> ^
>> javamag/Main4.java:18: error: incompatible types: incompatible
>> parameter types in lambda expression
>> ToIntFunction<OptionalInt?> f = o -> {
>> ^
>> 2 errors
>>
>> Thanks,
>>
>> Ben
>
More information about the valhalla-dev
mailing list