Updated pattern match documents

John Rose john.r.rose at oracle.com
Tue Oct 2 05:43:32 UTC 2018

On Oct 1, 2018, at 9:48 PM, Tagir Valeev <amaembo at gmail.com> wrote:
> I tried to think how to break this. Some interesting cases could arise
> if nullable type patterns are allowed for instanceof (which could be
> useful sometimes):

Yes, the trailing structure of the pattern gets tangled up with the
right-context of a typical expression.

One way to fix that is to make "x instanceof P" have a much lower
precedence than "x instanceof C", where C is a name and P is a
pattern which is not a name.

We don't have a precedent grammar, but we can demand that the
right-context of "x instanceof P" is comma, close paren, or the like.
Like this:


Or this:


The practical effect of this will be to force people to put parentheses
around "x instanceof P" when there is ambiguity.

— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20181001/b82bbc90/attachment.html>

More information about the amber-spec-experts mailing list