Reference-default style

John Rose john.r.rose at
Fri Dec 20 21:46:06 UTC 2019

On Dec 20, 2019, at 12:04 PM, Brian Goetz <brian.goetz at> wrote:
> The other direction is plausible too (when `T extends InlineObject`), though I don't have compelling examples of this in mind right now, so its possible that this is only a one-way requirement.

You’ve already looked at this, but to spell out more details FTR:

Reversing arrows, as T.ref is useful as a return type, so T.inline is useful
an argument type.  T.ref as a return value means “might produce nulls”.
And conversely T.inline as an argument means “won’t accept nulls”.
Both are cases where the usual application of Postel’s Law needs an
explicit variance.  It’s really about nulls more than inlines per se.

That’s all very nice, but an erased generic which applies only to inlines
seems like a relatively useless generic.  (Could be failure of imagination,
though.)  And applying such a generic (with “T.inline” arguments) to
identity and reference types creates cognitive dissonance in the user

I guess T.notnull would be more honest, as far as generics are concerned.
But adding that (hello T! T?) is a new job, with lots of knock-on complexity.

So, no compelling examples (reasonable cost, good benefit), as you said.

— John

More information about the valhalla-spec-observers mailing list