summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 1f4ff7cc2d..1f8f13ae02 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -99,22 +99,13 @@ trait Contexts { self: Analyzer =>
// there must be a scala.xml package when xml literals were parsed in this unit
if (unit.hasXml && ScalaXmlPackage == NoSymbol)
- unit.error(unit.firstXmlPos, "XML literals may only be used if the package scala.xml is present in the compilation classpath.")
-
- // TODO: remove the def below and drop `|| predefDefinesDollarScope` in the condition for `contextWithXML`
- // as soon as 2.11.0-M4 is released and used as STARR (and $scope is no longer defined in Predef)
- // Until then, to allow compiling quick with pre-2.11.0-M4 STARR,
- // which relied on Predef defining `val $scope`, we've left it in place.
- // Since the new scheme also imports $scope (as an alias for scala.xml.TopScope),
- // we must check whether it is still there and not import the alias to avoid ambiguity.
- // (All of this is only necessary to compile the full quick stage with STARR.
- // if using locker, Predef.$scope is no longer needed.)
- def predefDefinesDollarScope = definitions.getMemberIfDefined(PredefModule, nme.dollarScope) != NoSymbol
-
- // hack for the old xml library (detected by looking for scala.xml.TopScope, which needs to be in scope as $scope)
- // import scala.xml.{TopScope => $scope}
+ unit.error(unit.firstXmlPos, "To compile XML syntax, the scala.xml package must be on the classpath.\nPlease see https://github.com/scala/scala/wiki/Scala-2.11#xml.")
+
+ // scala-xml needs `scala.xml.TopScope` to be in scope globally as `$scope`
+ // We detect `scala-xml` by looking for `scala.xml.TopScope` and
+ // inject the equivalent of `import scala.xml.{TopScope => $scope}`
val contextWithXML =
- if (!unit.hasXml || ScalaXmlTopScope == NoSymbol || predefDefinesDollarScope) rootImportsContext
+ if (!unit.hasXml || ScalaXmlTopScope == NoSymbol) rootImportsContext
else rootImportsContext.make(gen.mkImport(ScalaXmlPackage, nme.TopScope, nme.dollarScope))
val c = contextWithXML.make(tree, unit = unit)