mber-dev" <
>> amber-dev@openjdk.org>
>> > Sent: Friday, September 5, 2025 4:30:06 PM
>> > Subject: Re: Question on Primitive Types in Patterns
>>
>> >>
>> >> I've been giving a presentation on Patterns in the Java language
I've been giving a presentation on Patterns in the Java language and
including some puzzles. The recent inclusion of Primitive Types in
Patterns has provided some interesting material. I currently have one
puzzle that I can't quite explain; hopefully someone on the mailing
list can provide
The *Integer* can't auto-box *byte*; therefore, it is not pattern dominance.
On Fri, Sep 5, 2025 at 9:02 AM Deepak Vohra wrote:
> Are you using a Java version that supports pattern matching for switch
> (JDK 17+ as a preview feature, standardized in JDK 21)? Or, it is a bug.
>
> On Fri, Sep 5, 2
wrote:
> - Original Message -
> > From: "Brian Goetz"
> > To: "Simon Ritter" , "amber-dev" <
> amber-dev@openjdk.org>
> > Sent: Friday, September 5, 2025 4:30:06 PM
> > Subject: Re: Question on Primitive Types in Patterns
&
- Original Message -
> From: "Brian Goetz"
> To: "Simon Ritter" , "amber-dev"
> Sent: Friday, September 5, 2025 4:30:06 PM
> Subject: Re: Question on Primitive Types in Patterns
>>
>> I've been giving a presentation on Patter
Detailed answer:
The compiler does check for pattern dominance to prevent unreachable code;
however, it uses the formal definition of pattern dominance. A pattern P1
(the first case) dominates a pattern P2 (the second case) if every possible
value that matches P2 would also match P1. The compiler
Are you using a Java version that supports pattern matching for switch (JDK
17+ as a preview feature, standardized in JDK 21)? Or, it is a bug.
On Fri, Sep 5, 2025 at 7:09 AM Simon Ritter wrote:
> Hi,
> I've been giving a presentation on Patterns in the Java language and
> including some puzzles