aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-01-15 21:46:25 +1100
committerMartin Odersky <odersky@gmail.com>2017-01-15 21:46:25 +1100
commiteb1063725d74395a86b3191fc658b7963f07c4b5 (patch)
treee913c46b4034c9a596027a3b179cc897013b5531 /compiler/src/dotty/tools/dotc/typer/Namer.scala
parentba7e12999dc645dbcba04cf365dfd4d621ee4662 (diff)
downloaddotty-eb1063725d74395a86b3191fc658b7963f07c4b5.tar.gz
dotty-eb1063725d74395a86b3191fc658b7963f07c4b5.tar.bz2
dotty-eb1063725d74395a86b3191fc658b7963f07c4b5.zip
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.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Namer.scala11
1 files changed, 8 insertions, 3 deletions
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)