Re: Question on Primitive Types in Patterns

2025-09-07 Thread Deepak Vohra
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

Re: Question on Primitive Types in Patterns

2025-09-06 Thread Brian Goetz
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

Re: Question on Primitive Types in Patterns

2025-09-05 Thread Deepak Vohra
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

Re: Question on Primitive Types in Patterns

2025-09-05 Thread David Alayachew
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 &

Re: Question on Primitive Types in Patterns

2025-09-05 Thread Remi Forax
- 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

Re: Question on Primitive Types in Patterns

2025-09-05 Thread Deepak Vohra
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

Re: Question on Primitive Types in Patterns

2025-09-05 Thread Deepak Vohra
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