Pattern Matching for instanceof (Preview 2)

Brian Goetz brian.goetz at
Thu Feb 6 23:26:54 UTC 2020

>> Conveniently, an inferred type pattern _is_ an any pattern.  (See the
>> explanation in the recent discussion on nullity, where this fell out
>> nicely.)   So semantically a var pattern is an any pattern.
> not if there are multiple de-constructors with the same arity, right ?

It still is an _any_ pattern.  If there are multiple same-arity dtors, 
we have an overload selection problem.  And we'd have the same overload 
selection whether the client said `case Foo(var x)` and `case 
Foo(__ANY_PATTERN__)`, because in neither case is there enough type 
information at the use site to perform the overload selection.

More information about the amber-spec-experts mailing list