-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
The dotc_core test fails when Config.cacheImplicitScopes is false (normally, it is set to true). The same failure also occurs even when cacheImplicitScopes is true but AnnotatedTypes are present, because scopes for AnnotatedTypes are never cached.
The following method in Implicits.scala looks suspicious:
def iscope(tp: Type, isLifted: Boolean = false): OfTypeImplicits =
if (tp.hash == NotCached || !Config.cacheImplicitScopes)
ofTypeImplicits(collectCompanions(tp))
else implicitScopeCache get tp match {
case Some(is) => is
case None =>
val savedEphemeral = ctx.typerState.ephemeral
ctx.typerState.ephemeral = false
try {
val liftedTp = if (isLifted) tp else liftToClasses(tp)
val result =
if (liftedTp ne tp) iscope(liftedTp, isLifted = true)
else ofTypeImplicits(collectCompanions(tp))
if (ctx.typerState.ephemeral) record("ephemeral cache miss: implicitScope")
else implicitScopeCache(tp) = result
result
}
finally ctx.typerState.ephemeral |= savedEphemeral
}When a type is looked up in the cache but is not found, the code sets the typer state to ephemeral and calls liftToClasses on the type. However, when a type is not looked up in the cache at all, none of this happens, and the code just calls ofTypeImplicits(collectCompanions(tp)) directly.
It would seem that the behaviour ought to be the same in the case of a cache miss as in the case that the cache is not used at all.
Metadata
Metadata
Assignees
Labels
No labels