Skip to content

Fix #1976: Hack to support scala.xml's $scope #1977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ class Definitions {
lazy val EqType = ctx.requiredClassRef("scala.Eq")
def EqClass(implicit ctx: Context) = EqType.symbol.asClass

lazy val XMLTopScopeModuleRef = ctx.requiredModuleRef("scala.xml.TopScope")

// Annotation base classes
lazy val AnnotationType = ctx.requiredClassRef("scala.annotation.Annotation")
def AnnotationClass(implicit ctx: Context) = AnnotationType.symbol.asClass
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ object StdNames {
val nullRuntimeClass: N = "scala.runtime.Null$"

val synthSwitch: N = "$synthSwitch"
val _scope: N = "$scope"

// unencoded operators
object raw {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(implicit ctx: Cont
val _buf: TermName = "$buf"
val _md: TermName = "$md"
val _plus: TermName = "$amp$plus"
val _scope: TermName = "$scope"
val _tmpscope: TermName = "$tmpscope"
val _xml: TermName = "xml"
}
Expand Down
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val ownType =
if (rawType.exists)
ensureAccessible(rawType, superAccess = false, tree.pos)
else if (name == nme._scope) {
// gross hack to support current xml literals.
// awaiting a better implicits based solution for library-supported xml
return ref(defn.XMLTopScopeModuleRef)
}
else
errorType(new MissingIdent(tree, kind, name.show), tree.pos)

Expand Down
4 changes: 4 additions & 0 deletions tests/pos/i1976.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
object Test {
import scala.xml._
val node = <node>{ "whatever " }</node>
}