Skip to content

Commit 650bec9

Browse files
committed
Move findMember count tracking from TypeComparer to Context
Typecomparer is not a good place because it gets re-generated for new context, which causes the counts to be reset.
1 parent 0ded263 commit 650bec9

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ object Contexts {
165165
_typeComparer
166166
}
167167

168+
/** Number of findMember calls on stack */
169+
private[core] var findMemberCount: Int = 0
170+
171+
/** List of names which have a findMemberCall on stack,
172+
* after Config.LogPendingFindMemberThreshold is reached.
173+
*/
174+
private[core] var pendingMemberSearches: List[Name] = Nil
175+
168176
/** The new implicit references that are introduced by this scope */
169177
private var implicitsCache: ContextualImplicits = null
170178
def implicits: ContextualImplicits = {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
2525
private var pendingSubTypes: mutable.Set[(Type, Type)] = null
2626
private var recCount = 0
2727

28-
private[core] var findMemberCount = 0
29-
private[core] var pendingMemberSearches: List[Name] = Nil
30-
3128
private var needsGc = false
3229

3330
/** Is a subtype check in progress? In that case we may not

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ object Types {
455455
val jointInfo =
456456
if (rinfo.isAlias) rinfo
457457
else if (pdenot.info.isAlias) pdenot.info
458-
else if (ctx.typeComparer.pendingMemberSearches.contains(name)) safeAnd(pdenot.info, rinfo)
458+
else if (ctx.pendingMemberSearches.contains(name)) safeAnd(pdenot.info, rinfo)
459459
else pdenot.info & rinfo
460460
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
461461
} else
@@ -493,12 +493,12 @@ object Types {
493493
case _ => tp1 & tp2
494494
}
495495

496-
val cmp = ctx.typeComparer
497-
val recCount = cmp.findMemberCount
498-
cmp.findMemberCount = recCount + 1
499-
if (recCount >= Config.LogPendingFindMemberThreshold) {
500-
cmp.pendingMemberSearches = name :: cmp.pendingMemberSearches
496+
{ val recCount = ctx.findMemberCount + 1
497+
ctx.findMemberCount = recCount
498+
if (recCount >= Config.LogPendingFindMemberThreshold)
499+
ctx.pendingMemberSearches = name :: ctx.pendingMemberSearches
501500
}
501+
502502
try go(this)
503503
catch {
504504
case ex: MergeError =>
@@ -508,9 +508,10 @@ object Types {
508508
throw ex // DEBUG
509509
}
510510
finally {
511-
cmp.findMemberCount = recCount - 1
511+
val recCount = ctx.findMemberCount
512512
if (recCount >= Config.LogPendingFindMemberThreshold)
513-
cmp.pendingMemberSearches = cmp.pendingMemberSearches.tail
513+
ctx.pendingMemberSearches = ctx.pendingMemberSearches.tail
514+
ctx.findMemberCount = recCount - 1
514515
}
515516
}
516517

0 commit comments

Comments
 (0)