From eb1063725d74395a86b3191fc658b7963f07c4b5 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 15 Jan 2017 21:46:25 +1100 Subject: Adopt scala's scheme for root import hiding scalac hides a root import from Predef if there is an eplicit Predef import. We now do the same (previously we did this only if the overriding import undefined something, using a `x => _` syntax). To avoid cycles and races one had to be very careful not to force import symbols too early, so we now compare the name before the symbol proper. All this is likely temporary - the comment of ImportInfo#unimported points to a different, more systematic solution. --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/typer/Namer.scala') diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 1b6e437b5..068ef3e4b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -373,8 +373,13 @@ class Namer { typer: Typer => } /** A new context that summarizes an import statement */ - def importContext(sym: Symbol, selectors: List[Tree])(implicit ctx: Context) = - ctx.fresh.setImportInfo(new ImportInfo(sym, selectors)) + def importContext(imp: Import, sym: Symbol)(implicit ctx: Context) = { + val impNameOpt = imp.expr match { + case ref: RefTree => Some(ref.name.asTermName) + case _ => None + } + ctx.fresh.setImportInfo(new ImportInfo(sym, imp.selectors, impNameOpt)) + } /** A new context for the interior of a class */ def inClassContext(selfInfo: DotClass /* Should be Type | Symbol*/)(implicit ctx: Context): Context = { @@ -423,7 +428,7 @@ class Namer { typer: Typer => setDocstring(pkg, stat) ctx case imp: Import => - importContext(createSymbol(imp), imp.selectors) + importContext(imp, createSymbol(imp)) case mdef: DefTree => val sym = enterSymbol(createSymbol(mdef)) setDocstring(sym, origStat) -- cgit v1.2.3