aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-01-12 22:12:03 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-05-31 16:53:24 +0200
commit818bf0b2aa3ec7544bb328aaad2b2bd75e724787 (patch)
tree22199bbe6f11b99eb51edf65f20c5149fce41bc6 /src
parentbe418e06756a3b8ddc3f748008995155260eb7ae (diff)
downloaddotty-818bf0b2aa3ec7544bb328aaad2b2bd75e724787.tar.gz
dotty-818bf0b2aa3ec7544bb328aaad2b2bd75e724787.tar.bz2
dotty-818bf0b2aa3ec7544bb328aaad2b2bd75e724787.zip
Fix implicit scope caching bug
The issue is subtle: the `tp` in scope in `def ofTypeImplicits` is the `tp` passed to the top-level `implicitScope` method, not the `tp` passed to the recursively called `iscope`, this means that before this commit, all intermediate `OfTypeImplicit` scopes cached while computing an implicit scope had their `tp` field incorrectly set, which means that we could miss implicits in later implicit searches. Note that the `implicit_cache.scala` test worked before this commit because of the restrictions on caching that exist since b8b0f381ef2cbcb7bad66fd3e7a9ae929baa45f6, it is included anyway because our caching strategy might change in the future.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index b3a1010cb..44689d758 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -338,8 +338,6 @@ trait ImplicitRunInfo { self: RunInfo =>
}
}
- def ofTypeImplicits(comps: TermRefSet) = new OfTypeImplicits(tp, comps)(ctx)
-
/** The implicit scope of type `tp`
* @param isLifted Type `tp` is the result of a `liftToClasses` application
*/
@@ -349,9 +347,12 @@ trait ImplicitRunInfo { self: RunInfo =>
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))
+ val refs =
+ if (liftedTp ne tp)
+ iscope(liftedTp, isLifted = true).companionRefs
+ else
+ collectCompanions(tp)
+ val result = new OfTypeImplicits(tp, refs)(ctx)
if (ctx.typerState.ephemeral) record("ephemeral cache miss: implicitScope")
else if (cacheResult) implicitScopeCache(tp) = result
result