RefObject and ValObject
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Apr 15 22:29:08 UTC 2019
On 15/04/2019 21:54, forax at univ-mlv.fr wrote:
> m(List<Object> list ) { ... }
> ...
> m(List.of(new Foo(), new Bar()));
>
Slightly incorrect sir :-)
This is effectively equivalent to the example I wrote earlier
List<Object> list = List.of(...)
The expected type will force the equality constraint and will drive
inference home.
Otherwise it would not even work today in cases when you pass e.g.
Integer and String to List.of, as their common supertype is something
sharper than Object. This stuff used indeed to fail pre-Java 8, but I
think we cured most of the issues. The remaining ones are when inference
eagerly resolves variables w/o looking at the target, because a target
is not there, as for 'var', or because the expression is in a receiver
position, as in:
List<Object> list2 = List.of(new Foo(), new Bar()).subList(0, 42);
Now, this will fail, but I believe we're in the corner^2 territory?
Maurizio
More information about the valhalla-spec-observers
mailing list