----- Original Message ----- > From: "John Rose" <[email protected]> > To: "Remi Forax" <[email protected]> > Cc: "Jesper Steen Møller" <[email protected]>, "Ilyas Selimov" > <[email protected]>, "amber-spec-experts" > <[email protected]> > Sent: Samedi 4 Septembre 2021 20:09:24 > Subject: Re: Dominance in pattern matching for switch: Spec and Javac > inconsistency
> On Sep 3, 2021, at 7:00 AM, [email protected] wrote: >> >> >> but a guarded switch dominates it's prefix, >> e.eg >> case Integer i && foo(i) dominates case Integer. >> >> But there is no rule between a guarded pattern like case Integer i && foo(i) >> and >> case 1, so they can appear in any order. >> > > Surely that’s a simple oversight. > > FWIW, it would be possible to convert reasoning about value-set > inclusion to reasoning about type dominance, in this case, by > simulating T x && g(x) as an existential type (? extends T). > > I think that simulation has the right properties for guards, > which is that (a) no two guards denote the same static value > set and (b) any guarded value set is a subset (possibly improper) > of the corresponding unguarded value set. yes, apart that we can detect the case where both guards are identical. something we currently do not do BTW. Rémi
