Skip to content

Commit 613ca2d

Browse files
Restore text on instantiation in type patterns
1 parent 973ee84 commit 613ca2d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

docs/docs/reference/new-types/match-types.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,17 @@ The compiler implements the following reduction algorithm:
101101
- Sequentially consider each pattern `Pi`
102102
- If `S <: Pi` reduce to `Ti`.
103103
- Otherwise, try constructing a proof that `S` and `Pi` are disjoint, or, in other words, that no value `s` of type `S` is also of type `Pi`.
104-
- If such proof is found, proceed to the case (`Pi+1`), otherwise, do not reduce.
104+
- If such proof is found, proceed to the next case (`Pi+1`), otherwise, do not reduce.
105105

106106
Disjointness proofs rely on the following properties of Scala types:
107107

108108
1. Single inheritance of classes
109109
2. Final classes cannot be extended
110110
3. Constant types with distinct values are nonintersecting
111111

112+
Type parameters in patterns are minimally instantiated when computing `S <: Pi`. An instantiation `Is` is _minimal_ for `Xs` if all type variables in `Xs` that appear covariantly and nonvariantly in `Is` are as small as possible and all type variables in `Xs` that appear contravariantly in `Is` are as large as possible. Here, "small" and "large" are understood with respect to `<:`.
113+
114+
For simplicity, we have omitted constraint handling so far. The full formulation of subtyping tests describes them as a function from a constraint and a pair of types to either _success_ and a new constraint or _failure_. In the context of reduction, the subtyping test `S <: [Xs := Is] P` is understood to leave the bounds of all variables in the input constraint unchanged, i.e. existing variables in the constraint cannot be instantiated by matching the scrutinee against the patterns.
112115

113116
## Subtyping Rules for Match Types
114117

0 commit comments

Comments
 (0)