Skip to content

Commit 09d2bf7

Browse files
committed
ImportInfo: Do not capture Context
1 parent 3b0209c commit 09d2bf7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/typer/ImportInfo.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ object ImportInfo {
1313
/** The import info for a root import from given symbol `sym` */
1414
def rootImport(refFn: () => TermRef)(implicit ctx: Context) = {
1515
val selectors = untpd.Ident(nme.WILDCARD) :: Nil
16-
def expr = tpd.Ident(refFn())
17-
def imp = tpd.Import(expr, selectors)
18-
new ImportInfo(imp.symbol, selectors, None, isRootImport = true)
16+
def expr(implicit ctx: Context) = tpd.Ident(refFn())
17+
def imp(implicit ctx: Context) = tpd.Import(expr, selectors)
18+
new ImportInfo(implicit ctx => imp.symbol, selectors, None, isRootImport = true)
1919
}
2020
}
2121

@@ -27,14 +27,14 @@ object ImportInfo {
2727
* @param isRootImport true if this is one of the implicit imports of scala, java.lang,
2828
* scala.Predef or dotty.DottyPredef in the start context, false otherwise.
2929
*/
30-
class ImportInfo(symf: => Symbol, val selectors: List[untpd.Tree],
30+
class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree],
3131
symNameOpt: Option[TermName], val isRootImport: Boolean = false)(implicit ctx: Context) {
3232

3333
// Dotty deviation: we cannot use a lazy val here for the same reason
3434
// that we cannot use one for `DottyPredefModuleRef`.
35-
def sym = {
35+
def sym(implicit ctx: Context) = {
3636
if (mySym == null) {
37-
mySym = symf
37+
mySym = symf(ctx)
3838
assert(mySym != null)
3939
}
4040
mySym

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class Namer { typer: Typer =>
378378
case ref: RefTree => Some(ref.name.asTermName)
379379
case _ => None
380380
}
381-
ctx.fresh.setImportInfo(new ImportInfo(sym, imp.selectors, impNameOpt))
381+
ctx.fresh.setImportInfo(new ImportInfo(implicit ctx => sym, imp.selectors, impNameOpt))
382382
}
383383

384384
/** A new context for the interior of a class */

0 commit comments

Comments
 (0)