aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/Compiler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-16 18:38:03 +0100
committerTobias Schlatter <tobias@meisch.ch>2014-03-21 11:24:03 +0100
commit4b57b3d877ca7b66b4cb2e588493d2933ae041bf (patch)
treecd68fb941a5a9eb2122f828f2670848ef3d750fe /src/dotty/tools/dotc/Compiler.scala
parentee1251f37f844bdb4f4ea69177e8183ad74e7b3d (diff)
downloaddotty-4b57b3d877ca7b66b4cb2e588493d2933ae041bf.tar.gz
dotty-4b57b3d877ca7b66b4cb2e588493d2933ae041bf.tar.bz2
dotty-4b57b3d877ca7b66b4cb2e588493d2933ae041bf.zip
Fix of t0504: _root_ not found
_root_ is now entered into an enclosing context.
Diffstat (limited to 'src/dotty/tools/dotc/Compiler.scala')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index c2f21f639..286ed3456 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -5,6 +5,7 @@ import core._
import Contexts._
import Periods._
import Symbols._
+import Scopes._
import typer.{FrontEnd, Typer, Mode, ImportInfo}
import reporting.ConsoleReporter
import dotty.tools.dotc.core.Phases.Phase
@@ -28,16 +29,28 @@ class Compiler {
runId += 1; runId
}
+ /** Produces the following contexts, from outermost to innermost
+ *
+ * bootStrap: A context with next available runId and a scope consisting of
+ * the RootPackage _root_
+ * start A context with RootClass as owner and the necessary initializations
+ * for type checking.
+ * imports For each element of RootImports, an import context
+ */
def rootContext(implicit ctx: Context): Context = {
ctx.definitions.init(ctx)
ctx.usePhases(phases)
- val start = ctx.fresh
+ val rootScope = new MutableScope
+ val bootstrap = ctx.fresh
.withPeriod(Period(nextRunId, FirstPhaseId))
+ .withScope(rootScope)
+ rootScope.enter(ctx.definitions.RootPackage)(bootstrap)
+ val start = bootstrap.fresh
.withOwner(defn.RootClass)
.withTyper(new Typer)
.withNewMode(Mode.ImplicitsEnabled)
.withTyperState(new MutableTyperState(ctx.typerState, new ConsoleReporter()(ctx), isCommittable = true))
- ctx.definitions.init(start)
+ ctx.definitions.init(start) // set context of definitions to start
def addImport(ctx: Context, sym: Symbol) =
ctx.fresh.withImportInfo(ImportInfo.rootImport(sym)(ctx))
(start.withRunInfo(new RunInfo(start)) /: defn.RootImports)(addImport)