Refined type checking for GADTs (was: Pattern matching: next steps after JEP 405)

2022-05-24 Thread Brian Goetz
 - *Refined type checking for GADTs. *Given a hierarchy like:     sealed interface Node { }     record IntNode(int i) implements Node { }     record FloatNode(float f) implements Node { } we currently cannot type-check programs like:     Node twice(Node n) {         return switch (n) {     

Re: Pattern matching: next steps after JEP 405

2022-05-20 Thread Brian Goetz
AM, Remi Forax wrote: *From: *"Brian Goetz" *To: *"amber-spec-experts" *Sent: *Wednesday, May 18, 2022 9:18:01 PM *Subject: *Pattern matching: next steps after JEP 405 JEP 405 has been proposed to target

Re: Pattern matching: next steps after JEP 405

2022-05-20 Thread Brian Goetz
*Cc: *"amber-spec-experts" *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

Re: Pattern matching: next steps after JEP 405

2022-05-20 Thread Remi Forax
> From: "Brian Goetz" > To: "amber-spec-experts" > Sent: Wednesday, May 18, 2022 9:18:01 PM > Subject: Pattern matching: next steps after JEP 405 > JEP 405 has been proposed to target for 19. But, it has some loose ends that > I'd > like to refin

Re: Pattern matching: next steps after JEP 405

2022-05-19 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "amber-spec-experts" > 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

Re: Pattern matching: next steps after JEP 405

2022-05-19 Thread Brian Goetz
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 reade

Re: Pattern matching: next steps after JEP 405

2022-05-19 Thread forax
> From: "Brian Goetz" > To: "Remi Forax" > Cc: "amber-spec-experts" > Sent: Wednesday, May 18, 2022 11:08:41 PM > Subject: Re: Pattern matching: next steps after JEP 405 >>> - Primitive patterns. This is driven by another existing asymme

Re: Pattern matching: next steps after JEP 405

2022-05-18 Thread Brian Goetz
Inference is also something we will need for pattern assignment   Box<>(var s) = box; Yes, it would work the same in all pattern contexts -- instanceof as well.  Every pattern context has a match target whose static type is known.  - *Array patterns. * The semantics of array patte

Re: Pattern matching: next steps after JEP 405

2022-05-18 Thread Remi Forax
> From: "Brian Goetz" > To: "amber-spec-experts" > Sent: Wednesday, May 18, 2022 9:18:01 PM > Subject: Pattern matching: next steps after JEP 405 > JEP 405 has been proposed to target for 19. But, it has some loose ends that > I'd > like to refin

Pattern matching: next steps after JEP 405

2022-05-18 Thread Brian Goetz
JEP 405 has been proposed to target for 19.  But, it has some loose ends that I'd like to refine before it eventually becomes a final feature.  These include:  - *Inference for record patterns. *Right now, we make you spell out the type parameters for a generic record pattern, such as:     c