aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Implicits.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-01-25 11:20:09 +1100
committerMartin Odersky <odersky@gmail.com>2017-02-08 19:35:58 +1100
commit971b233bc916ddbb4501f480500f9531fab99f78 (patch)
treecb5fc61663a56ff62d4df8fa92265c74cc8e58af /compiler/src/dotty/tools/dotc/typer/Implicits.scala
parentda7d7231b7f21fe1085abc569eb783590074a359 (diff)
downloaddotty-971b233bc916ddbb4501f480500f9531fab99f78.tar.gz
dotty-971b233bc916ddbb4501f480500f9531fab99f78.tar.bz2
dotty-971b233bc916ddbb4501f480500f9531fab99f78.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/tools/dotc/typer/Implicits.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Implicits.scala10
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
}