diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 26 |
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? |