Can't make simple Streams over indirect projects work

Brian Goetz brian.goetz at
Wed Aug 14 17:30:13 UTC 2019


We appreciate your exploring these corners.  But, just by way of setting 
expectations, there's nothing "simple" about this example; you're 
hitting on all the areas that are at the periphery of the L2 goals.  So 
while we would of course like for these things to work, we're not 
surprised there are pitfalls and interactions.  (I say this because I 
want to avoid having the "simple" framing derail the discussion.)

> all my attempts to use it, eg. via code like this:
> List<Optional?<Integer>> opts = new ArrayList<>();

The interaction of generic instantiation and the nullable projection 
type are definitely in the corners right now.  This would be spelled 
`Optional<Integer>?`, though; the `?` applies to the final (inline) 
type, not to the base type.  (You would spell the raw type 
`Optional?`.)  But, I suspect in the current prototype, that syntax will 
not work either.

But yes, it should be possible to project the type `Optional<Integer>` 
to a nullable projection.

More information about the valhalla-dev mailing list