Pattern Matching

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Mar 27 12:10:48 UTC 2017


Hi Andrey


On 27/03/17 12:04, Andrey Breslav wrote:
> 3. And to share a little bit about smart casts (I'm flattered that you 
> are using our terminology here ;) ): as soon as you have smart casts, 
> the urge to get intersection types into the language strengthens, 
> because of cases like this:
>
> if (x is A) {
>     if (x is B) {
>         // x is A&B here
>     }
> }
>
> We still get away without making intersection types explicit, and will 
> probably not add them in the very nearest future, but they become a 
> lot less exotic with smart casts.
Interesting point - our current scoping rules would claim that it is an 
error to introduce a binding for 'x' with type T, if 'x' is already in 
scope with a type S != T.

Do you have any compelling use cases from Kotlin to go down the more 
precise (and liberal) intersection type path?

Cheers
Maurizio


More information about the amber-spec-experts mailing list