[External] : Re: Patterns and GADTs (was: Reviewing feedback on patterns in switch)

forax at univ-mlv.fr forax at univ-mlv.fr
Wed Jan 26 14:16:35 UTC 2022


> From: "Brian Goetz" <brian.goetz at oracle.com>
> To: "Remi Forax" <forax at univ-mlv.fr>
> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Sent: Wednesday, January 26, 2022 1:28:19 PM
> Subject: Re: [External] : Re: Patterns and GADTs (was: Reviewing feedback on
> patterns in switch)

>> 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.)

sure, 

sealed interface Node<T> { } 
record A<T>(T t) implements Node<T> { } 
record B(String s) implements Node<String> { } 

void foo(Object o) { } 
void foo(List<String> list) { } 

<T> void m() { 
if (node instanceof B b) { 
foo(List.<T>of()); 
} 
} 

Rémi 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20220126/c98dddea/attachment.htm>


More information about the amber-spec-experts mailing list