Here’s a proposal to add intersection types to Scala 3. An intersection type `A & B`

replaces a compound type `A with B`

. Intersection types have nice algebraic properties, in particular, they are commutative. Intersection types have been studied formally in DOT and are implemented in Dotty.

Here’s a link to the doc page: https://dotty.epfl.ch/docs/reference/intersection-types.html

### Motivation

Intersection types have a solid theory and nice algebraic laws. They greatly improve in both respects on compound types.

### Migration

For the moment, the compound syntax `A with B`

is still available, in order to allow cross building between Scala 2 and 3. But it maps already to the intersection type semantics of `A & B`

. Compound types will be deprecated in Scala 3.1. There is a already an implemented rewrite rule to move from `with`

to `&`

.

This proposal is open for discussion in the community and will be discussed in our next SIP meeting, where we’ll take all your feedback into account for the approval/dismissal of this feature.