[External] : Re: Patterns and GADTs (was: Reviewing feedback on patterns in switch)
Brian Goetz
brian.goetz at oracle.com
Wed Jan 26 12:28:19 UTC 2022
The instanceof example is not a source backward compatible change, remember that instanceof is not a preview feature.
I’m well aware, can you give an example where flow typing of *type variables only* might lead to incompatibility? (I’m aware that this is a possibility, but you’re stating it like its a fact already on the table.) For example, where it would change overload selection (this is where flow typing for variables falls down, among other places.)
The main objection to that is that we do not have flow scoping for local variables but we have it for type variables which is weird.
We have inference for type variables when we don’t have them for types too. There are soooo many differences between type variables and ordinary type uses. But yes, this would be flow typing for type variables.
I wonder if we can come with an explicit syntax for it, the same way instanceof String s is an explicit syntax for local variables.
By example, something like
return switch (n) {
case A<T> n -> n.t;
case B n -> n.s as T=String;
};
but maybe it's too much ceremony.
Given the examples, I think this is something that stays better in the background.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20220126/ec98a79d/attachment-0001.htm>
More information about the amber-spec-experts
mailing list