@@ -337,25 +337,29 @@ trait ImplicitRunInfo { self: RunInfo =>
337
337
/** The implicit scope of type `tp`
338
338
* @param isLifted Type `tp` is the result of a `liftToClasses` application
339
339
*/
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
+
341
356
if (tp.hash == NotCached || ! Config .cacheImplicitScopes)
342
- ofTypeImplicits(collectCompanions(tp) )
357
+ computeIScope(cacheResult = false )
343
358
else implicitScopeCache get tp match {
344
359
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
+ }
359
363
360
364
iscope(tp)
361
365
}
0 commit comments