File tree 2 files changed +6
-4
lines changed
compiler/src/dotty/tools/dotc
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ trait PatternTypeConstrainer { self: TypeComparer =>
14
14
/** Derive type and GADT constraints that necessarily follow from a pattern with the given type matching
15
15
* a scrutinee of the given type.
16
16
*
17
- * We have the following situation in case of a (dynamic) pattern match:
17
+ * This function breaks down scrutinee and pattern types into subcomponents between which there must be
18
+ * a subtyping relationship, and derives constraints from those relationships. We have the following situation
19
+ * in case of a (dynamic) pattern match:
18
20
*
19
21
* StaticScrutineeType PatternType
20
22
* \ /
Original file line number Diff line number Diff line change @@ -1094,9 +1094,9 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1094
1094
fullyDefinedType(unapplyArgType, " pattern selector" , tree.span)
1095
1095
selType.dropAnnot(defn.UncheckedAnnot ) // need to drop @unchecked. Just because the selector is @unchecked, the pattern isn't.
1096
1096
} else {
1097
- // note that we simply ignore whether constraining actually succeeded or not
1098
- // in theory, constraining should only fail if the pattern cannot possibly match
1099
- // however, during exhaustivity checks, we perform a strictly better check
1097
+ // We ignore whether constraining the pattern succeeded.
1098
+ // Constraining only fails if the pattern cannot possibly match,
1099
+ // but useless pattern checks detect more such cases, so we simply rely on them instead.
1100
1100
ctx.addMode(Mode .GADTflexible ).typeComparer.constrainPatternType(unapplyArgType, selType)
1101
1101
val patternBound = maximizeType(unapplyArgType, tree.span, fromScala2x)
1102
1102
if (patternBound.nonEmpty) unapplyFn = addBinders(unapplyFn, patternBound)
You can’t perform that action at this time.
0 commit comments