diff options
author | Martin Odersky <odersky@gmail.com> | 2017-01-25 11:20:09 +1100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-01-31 16:14:18 +1100 |
commit | 30f3ea1710203b7ccd004bdee414389342d589dc (patch) | |
tree | 322c063a377ec04c7036bf39c8da25b2fd831b37 /compiler/src/dotty | |
parent | d087448fdffff8f64a23d9db39445455cddc2fc6 (diff) | |
download | dotty-30f3ea1710203b7ccd004bdee414389342d589dc.tar.gz dotty-30f3ea1710203b7ccd004bdee414389342d589dc.tar.bz2 dotty-30f3ea1710203b7ccd004bdee414389342d589dc.zip |
Avoid recomputation of companionRefs
The previous condition for caching companionRefs contained a condition
result.companionRefs.forall(implicitScopeCache.contains)
which was always false because we cache types in `implicitCodeCache`, not
companion refs. The new logic fixes this and does not need a second traversal
because it is integrated in `iscopeRefs`.
Diffstat (limited to 'compiler/src/dotty')
-rw-r--r-- | compiler/src/dotty/tools/dotc/typer/Implicits.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 592e80048..0b1eb1afb 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -380,7 +380,9 @@ trait ImplicitRunInfo { self: RunInfo => EmptyTermRefSet // on the other hand, the refs of `tp` are now not accurate, so `tp` is marked incomplete. } else { seen += t - iscope(t).companionRefs + val is = iscope(t) + if (!implicitScopeCache.contains(t)) incomplete += tp + is.companionRefs } } @@ -436,10 +438,8 @@ trait ImplicitRunInfo { self: RunInfo => if (ctx.typerState.ephemeral) record("ephemeral cache miss: implicitScope") else if (canCache && - ((tp eq rootTp) || // first type traversed is always cached - !incomplete.contains(tp) && // other types are cached if they are not incomplete - result.companionRefs.forall( // and all their companion refs are cached - implicitScopeCache.contains))) + ((tp eq rootTp) || // first type traversed is always cached + !incomplete.contains(tp))) // other types are cached if they are not incomplete implicitScopeCache(tp) = result result } |