Skip to content

Commit d42301e

Browse files
committed
Move comment for stripLazyRef usage
1 parent d087c43 commit d42301e

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3248,19 +3248,6 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
32483248
MatchTypeTrace.noInstance(scrut, cas, fails)
32493249
NoType
32503250
case MatchResult.Reduced(tp) =>
3251-
// A recursive match type will have the recursive call
3252-
// wrapped in a LazyRef. For example in i18175, the recursive calls
3253-
// to IsPiped within the definition of IsPiped are all wrapped in LazyRefs.
3254-
// In addition to that, TypeMaps, such as the one that backs TypeOps.simplify,
3255-
// by default will rewrap a LazyRef when applying its function.
3256-
// The result of those two things means that given a big enough input
3257-
// that recursive enough times through one or multiple match types,
3258-
// reducing and simplifying the result of the case bodies,
3259-
// can end up with a large stack of directly-nested lazy refs.
3260-
// And if that nesting level breaches `Config.LogPendingSubTypesThreshold`,
3261-
// then TypeComparer will eventually start returning `false` for `isSubType`.
3262-
// Or, under -Yno-deep-subtypes, start throwing AssertionErrors.
3263-
// So, we eagerly strip that lazy ref here to avoid the stacking.
32643251
tp.simplified
32653252
case Nil =>
32663253
val casesText = MatchTypeTrace.noMatchesText(scrut, cases)

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,8 +1985,19 @@ object Types {
19851985
* except for replacing type parameters with associated type variables.
19861986
*/
19871987
def simplified(using Context): Type =
1988-
// stripping LazyRef is important for the reduction of applied match types
1989-
// see the comment in matchCases/recur for more details
1988+
// A recursive match type will have the recursive call
1989+
// wrapped in a LazyRef. For example in i18175, the recursive calls
1990+
// to IsPiped within the definition of IsPiped are all wrapped in LazyRefs.
1991+
// In addition to that, TypeMaps, such as the one that backs TypeOps.simplify,
1992+
// by default will rewrap a LazyRef when applying its function.
1993+
// The result of those two things means that given a big enough input
1994+
// that recursive enough times through one or multiple match types,
1995+
// reducing and simplifying the result of the case bodies,
1996+
// can end up with a large stack of directly-nested lazy refs.
1997+
// And if that nesting level breaches `Config.LogPendingSubTypesThreshold`,
1998+
// then TypeComparer will eventually start returning `false` for `isSubType`.
1999+
// Or, under -Yno-deep-subtypes, start throwing AssertionErrors.
2000+
// So, we eagerly strip that lazy ref here to avoid the stacking.
19902001
val tp = stripLazyRef
19912002
TypeOps.simplify(tp, null)
19922003

0 commit comments

Comments
 (0)