Skip to content

Commit e63445f

Browse files
committed
Avoid crash in Positioned#checkPos for xml literals
1 parent 96b0ae4 commit e63445f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/SymbolicXMLBuilder.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,12 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(implicit ctx: Cont
247247
case (false, false) => (scopeDef :: metadataDef :: attributes, tmpScopeDef :: namespaces)
248248
}
249249

250+
val argsPos = Block(args.toList, EmptyTree).pos
251+
250252
val body = mkXML(
251-
pos.toSynthetic,
253+
argsPos, // Incorrect, but it seems impossible to get correct
254+
// non-overlapping positions without reworking the generation of
255+
// xml trees
252256
false,
253257
const(pre),
254258
const(newlabel),

tests/pos/xml-pos.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Test {
2+
val a =
3+
<foo a="bla" />
4+
5+
val b =
6+
<foo xmlns:bar="baz" />
7+
8+
val c =
9+
<a><c/></a>
10+
}

0 commit comments

Comments
 (0)