summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-07-09 11:32:58 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-07-17 15:48:24 +0200
commitb8503f6cf937b739341a6a387800c4542e81ae77 (patch)
tree75271a9e7ad6e14eb76d58d24281e27fbaa7c6e6 /src/compiler/scala/tools/nsc/typechecker/Contexts.scala
parent543bb3e0b60cd1e1d4a3e3be19ec90256cc13151 (diff)
downloadscala-b8503f6cf937b739341a6a387800c4542e81ae77.tar.gz
scala-b8503f6cf937b739341a6a387800c4542e81ae77.tar.bz2
scala-b8503f6cf937b739341a6a387800c4542e81ae77.zip
Restrict `contextMode` fiddling to `Context`
Introduce `initRootContext` to set the relevant bits.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 199209c5fa..6951ff2f0b 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -98,7 +98,7 @@ trait Contexts { self: Analyzer =>
}
- def rootContext(unit: CompilationUnit, tree: Tree = EmptyTree, erasedTypes: Boolean = false): Context = {
+ def rootContext(unit: CompilationUnit, tree: Tree = EmptyTree): Context = {
val rootImportsContext = (startContext /: rootImports(unit))((c, sym) => c.make(gen.mkWildcardImport(sym)))
// there must be a scala.xml package when xml literals were parsed in this unit
@@ -113,11 +113,17 @@ trait Contexts { self: Analyzer =>
else rootImportsContext.make(gen.mkImport(ScalaXmlPackage, nme.TopScope, nme.dollarScope))
val c = contextWithXML.make(tree, unit = unit)
- if (erasedTypes) c.setThrowErrors() else c.setReportErrors()
- c(EnrichmentEnabled | ImplicitsEnabled) = !erasedTypes
+ c.initRootContext()
c
}
+ def rootContextPostTyper(unit: CompilationUnit, tree: Tree = EmptyTree): Context = {
+ val c = rootContext(unit, tree)
+ c.initRootContextPostTyper()
+ c
+ }
+
+
def resetContexts() {
startContext.enclosingContextChain foreach { context =>
context.tree match {
@@ -511,6 +517,20 @@ trait Contexts { self: Analyzer =>
c
}
+ /** Use reporter (possibly buffered) for errors/warnings and enable implicit conversion **/
+ def initRootContext(): Unit = {
+ setReportErrors()
+ this(EnrichmentEnabled | ImplicitsEnabled) = true
+ }
+
+ /** Disable implicit conversion/enrichment, throw TypeError on error.
+ * TODO: can we phase out TypeError and uniformly rely on reporter?
+ */
+ def initRootContextPostTyper(): Unit = {
+ setThrowErrors()
+ this(EnrichmentEnabled | ImplicitsEnabled) = false
+ }
+
def make(tree: Tree, owner: Symbol, scope: Scope): Context =
// TODO SI-7345 Moving this optimization into the main overload of `make` causes all tests to fail.
// even if it is extened to check that `unit == this.unit`. Why is this?