summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-07-17 12:14:46 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-07-17 15:56:06 +0200
commitcdee8350288edb1054bfc841f81bd21b9e6a0323 (patch)
treeeea73eca20bbfcabe16e1890eceaf34b5f41cc7a /src/compiler/scala/tools/nsc/typechecker/Contexts.scala
parent064bc5eb25094f0d6de2aa8990466fed29d3c095 (diff)
downloadscala-cdee8350288edb1054bfc841f81bd21b9e6a0323.tar.gz
scala-cdee8350288edb1054bfc841f81bd21b9e6a0323.tar.bz2
scala-cdee8350288edb1054bfc841f81bd21b9e6a0323.zip
Configure `checking` mode in `rootContext`.
This is used by the tree checkers.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index e7ab9dc94e..7464837409 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): Context = {
+ def rootContext(unit: CompilationUnit, tree: Tree = EmptyTree, throwing: Boolean = false, checking: Boolean = false): 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,16 +113,13 @@ trait Contexts { self: Analyzer =>
else rootImportsContext.make(gen.mkImport(ScalaXmlPackage, nme.TopScope, nme.dollarScope))
val c = contextWithXML.make(tree, unit = unit)
- c.initRootContext()
- c
- }
- def rootContextPostTyper(unit: CompilationUnit, tree: Tree = EmptyTree): Context = {
- val c = rootContext(unit, tree)
- c.initRootContextPostTyper()
+ c.initRootContext(throwing, checking)
c
}
+ def rootContextPostTyper(unit: CompilationUnit, tree: Tree = EmptyTree): Context =
+ rootContext(unit, tree, throwing = true)
def resetContexts() {
startContext.enclosingContextChain foreach { context =>
@@ -492,19 +489,13 @@ trait Contexts { self: Analyzer =>
}
/** Use reporter (possibly buffered) for errors/warnings and enable implicit conversion **/
- def initRootContext(): Unit = {
- setReportErrors()
- setAmbiguousErrors(true)
- this(EnrichmentEnabled | ImplicitsEnabled) = true
- }
+ def initRootContext(throwing: Boolean = false, checking: Boolean = false): Unit = {
+ if (checking) this.checking = true
+ else if (throwing) setThrowErrors()
+ else setReportErrors()
- /** Disable implicit conversion/enrichment, throw TypeError on error.
- * TODO: can we phase out TypeError and uniformly rely on reporter?
- */
- def initRootContextPostTyper(): Unit = {
- setThrowErrors()
- setAmbiguousErrors(false)
- this(EnrichmentEnabled | ImplicitsEnabled) = false
+ setAmbiguousErrors(!throwing)
+ this(EnrichmentEnabled | ImplicitsEnabled) = !throwing
}
def make(tree: Tree, owner: Symbol, scope: Scope): Context =