aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-02-13 20:31:28 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-02-18 23:35:34 +0100
commite5a6a9e7c363acc4ad7d9d9fe25e1ffa533e5d90 (patch)
treefec1bac3256bb8baacf150678b96405819e4b115
parent8fe124f1517fba9cb833c82e52ba6f6ba01da735 (diff)
downloaddotty-e5a6a9e7c363acc4ad7d9d9fe25e1ffa533e5d90.tar.gz
dotty-e5a6a9e7c363acc4ad7d9d9fe25e1ffa533e5d90.tar.bz2
dotty-e5a6a9e7c363acc4ad7d9d9fe25e1ffa533e5d90.zip
ImportInfo: Do not capture Context
-rw-r--r--compiler/src/dotty/tools/dotc/typer/ImportInfo.scala12
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Namer.scala2
2 files changed, 7 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
index f7efb2ac2..3ba610ef2 100644
--- a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
+++ b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala
@@ -13,9 +13,9 @@ object ImportInfo {
/** The import info for a root import from given symbol `sym` */
def rootImport(refFn: () => TermRef)(implicit ctx: Context) = {
val selectors = untpd.Ident(nme.WILDCARD) :: Nil
- def expr = tpd.Ident(refFn())
- def imp = tpd.Import(expr, selectors)
- new ImportInfo(imp.symbol, selectors, None, isRootImport = true)
+ def expr(implicit ctx: Context) = tpd.Ident(refFn())
+ def imp(implicit ctx: Context) = tpd.Import(expr, selectors)
+ new ImportInfo(implicit ctx => imp.symbol, selectors, None, isRootImport = true)
}
}
@@ -27,14 +27,14 @@ object ImportInfo {
* @param isRootImport true if this is one of the implicit imports of scala, java.lang,
* scala.Predef or dotty.DottyPredef in the start context, false otherwise.
*/
-class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree],
+class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
symNameOpt: Option[TermName], val isRootImport: Boolean = false)(implicit ctx: Context) {
// Dotty deviation: we cannot use a lazy val here for the same reason
// that we cannot use one for `DottyPredefModuleRef`.
- def sym = {
+ def sym(implicit ctx: Context) = {
if (mySym == null) {
- mySym = symf
+ mySym = symf(ctx)
assert(mySym != null)
}
mySym
diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala
index 3860ba225..9f35a07ab 100644
--- a/compiler/src/dotty/tools/dotc/typer/Namer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala
@@ -378,7 +378,7 @@ class Namer { typer: Typer =>
case ref: RefTree => Some(ref.name.asTermName)
case _ => None
}
- ctx.fresh.setImportInfo(new ImportInfo(sym, imp.selectors, impNameOpt))
+ ctx.fresh.setImportInfo(new ImportInfo(implicit ctx => sym, imp.selectors, impNameOpt))
}
/** A new context for the interior of a class */