> From: "Brian Goetz" <[email protected]>
> To: "Remi Forax" <[email protected]>
> Cc: "amber-spec-experts" <[email protected]>
> 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