File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 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 =>
1414 /** Derive type and GADT constraints that necessarily follow from a pattern with the given type matching
1515 * a scrutinee of the given type.
1616 *
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:
1820 *
1921 * StaticScrutineeType PatternType
2022 * \ /
Original file line number Diff line number Diff line change @@ -1094,9 +1094,9 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
10941094 fullyDefinedType(unapplyArgType, " pattern selector" , tree.span)
10951095 selType.dropAnnot(defn.UncheckedAnnot ) // need to drop @unchecked. Just because the selector is @unchecked, the pattern isn't.
10961096 } 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.
11001100 ctx.addMode(Mode .GADTflexible ).typeComparer.constrainPatternType(unapplyArgType, selType)
11011101 val patternBound = maximizeType(unapplyArgType, tree.span, fromScala2x)
11021102 if (patternBound.nonEmpty) unapplyFn = addBinders(unapplyFn, patternBound)
You can’t perform that action at this time.
0 commit comments