Skip to content

Turn off position checking for XML-generated blocks #3235

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 1 commit into from
Oct 4, 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/ast/Positioned.scala
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ abstract class Positioned extends DotClass with Product {
}
if (nonOverlapping) {
this match {
case _: XMLBlock =>
// FIXME: Trees generated by the XML parser do not satisfy `checkPos`
case _: WildcardFunction
if lastPositioned.isInstanceOf[ValDef] && !p.isInstanceOf[ValDef] =>
// ignore transition from last wildcard parameter to body
Expand Down
4 changes: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
*/
class InfixOpBlock(leftOperand: Tree, rightOp: Tree) extends Block(leftOperand :: Nil, rightOp)

/** A block generated by the XML parser, only treated specially by
* `Positioned#checkPos` */
class XMLBlock(stats: List[Tree], expr: Tree) extends Block(stats, expr)

// ----- Modifiers -----------------------------------------------------
/** Mod is intended to record syntactic information about modifiers, it's
* NOT a replacement of FlagSet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,6 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(implicit ctx: Cont
args
)

atPos(pos.toSynthetic)( Block(nsResult, Block(attrResult, body)) )
atPos(pos.toSynthetic)(new XMLBlock(nsResult, new XMLBlock(attrResult, body)))
}
}
10 changes: 10 additions & 0 deletions tests/pos/xml-pos.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Test {
val a =
<foo a="bla" n="foo" />

val b =
<foo xmlns:bar="baz" />

val c =
<a><c/></a>
}