----- Mail original ----- > De: "Brian Goetz" <brian.go...@oracle.com> > À: "Remi Forax" <fo...@univ-mlv.fr> > Cc: "amber-spec-experts" <amber-spec-experts@openjdk.java.net> > Envoyé: Jeudi 20 Août 2020 22:37:24 > Objet: Re: [pattern-switch] Exhaustiveness
>> but it doesn't mean that in term of translation strategy we need all >> those cases as synthetic cases, installing some null checks upfront >> (of a pattern deconstruction) and a default should be enough, or am i >> missing something. > > They don't have to be implemented as individual synthetic cases, but it > is a reasonable mental model for purposes of discussing what should happen. > > But, depending on what mapping we make between the residue and > exceptions to be thrown, "null check + default" may not be a > sufficiently rich model. (It was for enums, but the shape of the > residue is more complicated here.) If our residue is null, and > Box(null), Box(novel), and we want want to extrapolate from the > exception rules we have for enums, then we are throwing different things > for Box(null) and Box(novel). Which is why synthetic cases might be a > more accurate starting point; we can express Box(null) and Box(novel) as > patterns. Having a meaningful error message with the pattern for both the NPE and ICCE is not enough ? Rémi