ValueType.findConstructor

John Rose john.r.rose at oracle.com
Mon Jun 26 19:08:18 UTC 2017


On Jun 26, 2017, at 11:43 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
> 
>   Point p = ...
>   if (p match Point(x, _, z))
>     return new Point(z, another_y , x)
>   else
>     throw new Error()

If you mean to swap z and x in the reconstruction,
it's a good example of an ad hoc reconstruction which
is more than just a "wither".

This makes me think there should be a warning
issued by the compiler if you choose a name for
a component of a match result which conflicts
with the name advertised by the constructor.
So "p match Point(z, y, x)" would get a warning
on the first and third arguments, if the constructor
were "Point(x, y, z)" and Point actually had those
names as part of its API.



More information about the valhalla-dev mailing list