On Oct 1, 2018, at 9:48 PM, Tagir Valeev <amae...@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: AssignmentExpression: ConditionalExpression PatternMatchExpression Assignment Or this: Expression: LambdaExpression PatternMatchExpression AssignmentExpression The practical effect of this will be to force people to put parentheses around "x instanceof P" when there is ambiguity. — John