@@ -337,25 +337,29 @@ trait ImplicitRunInfo { self: RunInfo =>
337337 /** The implicit scope of type `tp`
338338 * @param isLifted Type `tp` is the result of a `liftToClasses` application
339339 */
340- def iscope (tp : Type , isLifted : Boolean = false ): OfTypeImplicits =
340+ def iscope (tp : Type , isLifted : Boolean = false ): OfTypeImplicits = {
341+ def computeIScope (cacheResult : Boolean ) = {
342+ val savedEphemeral = ctx.typerState.ephemeral
343+ ctx.typerState.ephemeral = false
344+ try {
345+ val liftedTp = if (isLifted) tp else liftToClasses(tp)
346+ val result =
347+ if (liftedTp ne tp) iscope(liftedTp, isLifted = true )
348+ else ofTypeImplicits(collectCompanions(tp))
349+ if (ctx.typerState.ephemeral) record(" ephemeral cache miss: implicitScope" )
350+ else if (cacheResult) implicitScopeCache(tp) = result
351+ result
352+ }
353+ finally ctx.typerState.ephemeral |= savedEphemeral
354+ }
355+
341356 if (tp.hash == NotCached || ! Config .cacheImplicitScopes)
342- ofTypeImplicits(collectCompanions(tp) )
357+ computeIScope(cacheResult = false )
343358 else implicitScopeCache get tp match {
344359 case Some (is) => is
345- case None =>
346- val savedEphemeral = ctx.typerState.ephemeral
347- ctx.typerState.ephemeral = false
348- try {
349- val liftedTp = if (isLifted) tp else liftToClasses(tp)
350- val result =
351- if (liftedTp ne tp) iscope(liftedTp, isLifted = true )
352- else ofTypeImplicits(collectCompanions(tp))
353- if (ctx.typerState.ephemeral) record(" ephemeral cache miss: implicitScope" )
354- else implicitScopeCache(tp) = result
355- result
356- }
357- finally ctx.typerState.ephemeral |= savedEphemeral
358- }
360+ case None => computeIScope(cacheResult = true )
361+ }
362+ }
359363
360364 iscope(tp)
361365 }
0 commit comments