diff --git a/compiler/src/dotty/tools/dotc/ast/Positioned.scala b/compiler/src/dotty/tools/dotc/ast/Positioned.scala
index faa51d8a2eda..f8e53f29fb99 100644
--- a/compiler/src/dotty/tools/dotc/ast/Positioned.scala
+++ b/compiler/src/dotty/tools/dotc/ast/Positioned.scala
@@ -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
diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala
index 29fcea80dbad..4466a8342da2 100644
--- a/compiler/src/dotty/tools/dotc/ast/untpd.scala
+++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala
@@ -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.
diff --git a/compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala b/compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala
index 97b04669221b..ceef07d4ca36 100644
--- a/compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala
@@ -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)))
}
}
diff --git a/tests/pos/xml-pos.scala b/tests/pos/xml-pos.scala
new file mode 100644
index 000000000000..953b3a90c9d4
--- /dev/null
+++ b/tests/pos/xml-pos.scala
@@ -0,0 +1,10 @@
+object Test {
+ val a =
+
+
+ val b =
+
+
+ val c =
+
+}