Pattern matching: next steps after JEP 405

forax at forax at
Fri May 20 05:27:28 UTC 2022

> From: "Brian Goetz" <brian.goetz at>
> To: "Remi Forax" <forax at>
> Cc: "amber-spec-experts" <amber-spec-experts at>
> Sent: Thursday, May 19, 2022 3:05:07 PM
> Subject: Re: Pattern matching: next steps after JEP 405

>> When you have a type pattern X in a middle of a pattern *and* you have
>> conversions, then there is an ambiguity,
>> does instanceof Box(X x) means
>> Box(var v) && v instanceof X x
>> or
>> Box(var v) && X x = (X) v;

> This is not an ambiguity in the language, it is confusion on the part of the
> reader :)

> In any case, I'm not following your argument here.
If you have both a type pattern and allow conversions, you have 
Box(X) is equivalent to Box(var v) && v instanceof Y y && X x = (X) y 

How do you find Y ? 

And yes, the bar is not only that Y has to be unique for the compiler, it has also to be obvious for the human reader too. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the amber-spec-experts mailing list