Skip to content

Commit cb10bb7

Browse files
committed
Adjust comments
1 parent fabd1ae commit cb10bb7

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

compiler/src/dotty/tools/dotc/core/PatternTypeConstrainer.scala

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ trait PatternTypeConstrainer { self: TypeComparer =>
155155
// Their info could, for an example, be an AndType. One example where
156156
// this is important is an enum case that extends its parent and an
157157
// additional trait - argument-less enum cases desugar to vals.
158+
// See run/enum-Tree.scala.
158159
if tp.classSymbol.exists then tp else tp.info
159160
case tp => tp
160161
}
@@ -182,15 +183,15 @@ trait PatternTypeConstrainer { self: TypeComparer =>
182183

183184
/** Constrain "simple" patterns (see `constrainPatternType`).
184185
*
185-
* This function attempts to modify pattern and scrutinee type s.t. the pattern must be a subtype of the scrutinee,
186-
* or otherwise it cannot possibly match. In order to do that, we:
186+
* This function expects to receive two types (scrutinee and pattern), both
187+
* of which have class symbols, one of which is derived from another. If the
188+
* type "being derived from" is an applied type, it will 1) "upcast" the
189+
* deriving type to an applied type with the same constructor and 2) infer
190+
* constraints for the applied types' arguments that follow from both
191+
* types being inhabited by one value (the scrutinee).
187192
*
188-
* 1. Rely on `constrainPatternType` to break the actual scrutinee/pattern types into subcomponents
189-
* 2. Widen type parameters of scrutinee type that are not invariantly refined (see below) by the pattern type.
190-
* 3. Wrap the pattern type in a skolem to avoid overconstraining top-level abstract types in scrutinee type
191-
* 4. Check that `WidenedScrutineeType <: NarrowedPatternType`
192-
*
193-
* Importantly, note that the pattern type may contain type variables.
193+
* Importantly, note that the pattern type may contain type variables, which
194+
* are used to infer type arguments to Unapply trees.
194195
*
195196
* ## Invariant refinement
196197
* Essentially, we say that `D[B] extends C[B]` s.t. refines parameter `A` of `trait C[A]` invariantly if

0 commit comments

Comments
 (0)