@@ -42,12 +42,14 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
4242 val _Group : TypeName = " Group"
4343 val _MetaData : TypeName = " MetaData"
4444 val _NamespaceBinding : TypeName = " NamespaceBinding"
45+ val _Node : TypeName = " Node"
4546 val _NodeBuffer : TypeName = " NodeBuffer"
4647 val _PrefixedAttribute : TypeName = " PrefixedAttribute"
4748 val _ProcInstr : TypeName = " ProcInstr"
4849 val _Text : TypeName = " Text"
4950 val _Unparsed : TypeName = " Unparsed"
5051 val _UnprefixedAttribute : TypeName = " UnprefixedAttribute"
52+ val _Seq : TypeName = " Seq"
5153 }
5254
5355 private object xmlterms extends ScalaTermNames {
@@ -59,12 +61,13 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
5961 val _plus : TermName = " &+"
6062 val _tmpscope : TermName = " $tmpscope"
6163 val _xml : TermName = " xml"
64+ val _toVector : TermName = " toVector"
6265 }
6366
64- import xmltypes .{_Comment , _Elem , _EntityRef , _Group , _MetaData , _NamespaceBinding , _NodeBuffer ,
65- _PrefixedAttribute , _ProcInstr , _Text , _Unparsed , _UnprefixedAttribute }
67+ import xmltypes .{_Comment , _Elem , _EntityRef , _Group , _MetaData , _NamespaceBinding , _NodeBuffer , _Node ,
68+ _PrefixedAttribute , _ProcInstr , _Text , _Unparsed , _UnprefixedAttribute , _Seq }
6669
67- import xmlterms .{_Null , __Elem , __Text , _buf , _md , _plus , _scope , _tmpscope , _xml }
70+ import xmlterms .{_Null , __Elem , __Text , _buf , _md , _plus , _scope , _tmpscope , _xml , _toVector }
6871
6972 // convenience methods
7073 private def LL [A ](x : A * ): List [List [A ]] = List (x.toList)
@@ -89,6 +92,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
8992 private def _scala_xml_UnprefixedAttribute = _scala_xml(_UnprefixedAttribute)
9093 private def _scala_xml__Elem = _scala_xml(__Elem)
9194 private def _scala_xml__Text = _scala_xml(__Text)
95+ private def _scala_Seq_Node = AppliedTypeTree (_scala(_Seq), List (_scala_xml(_Node)))
9296
9397 /** Wildly wrong documentation deleted in favor of "self-documenting code." */
9498 protected def mkXML (
@@ -103,7 +107,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
103107 {
104108 def starArgs =
105109 if (children.isEmpty) Nil
106- else List (Typed (makeXMLseq(span, children), wildStar))
110+ else List (Typed (makeXMLseq(span, children, toVector = true ), wildStar))
107111
108112 def pat = Apply (_scala_xml__Elem, List (pre, label, wild, wild) ::: convertToTextPat(children))
109113 def nonpat = New (_scala_xml_Elem, List (List (pre, label, attrs, scope, if (empty) Literal (Constant (true )) else Literal (Constant (false ))) ::: starArgs))
@@ -152,7 +156,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
152156 ts match {
153157 case Nil => TypedSplice (tpd.ref(defn.NilModule ).withSpan(span))
154158 case t :: Nil => t
155- case _ => makeXMLseq(span, ts)
159+ case _ => makeXMLseq(span, ts, toVector = true )
156160 }
157161 }
158162
@@ -162,11 +166,12 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
162166 }
163167
164168 /** could optimize if args.length == 0, args.length == 1 AND args(0) is <: Node. */
165- def makeXMLseq (span : Span , args : collection.Seq [Tree ]): Block = {
169+ def makeXMLseq (span : Span , args : collection.Seq [Tree ], toVector : Boolean ): Block = {
166170 val buffer = ValDef (_buf, TypeTree (), New (_scala_xml_NodeBuffer, ListOfNil ))
167171 val applies = args filterNot isEmptyText map (t => Apply (Select (Ident (_buf), _plus), List (t)))
168172
169- atSpan(span)(new XMLBlock (buffer :: applies.toList, Ident (_buf)) )
173+ val res = if (toVector) Select (Ident (_buf), _toVector) else Ident (_buf)
174+ atSpan(span)(new XMLBlock (buffer :: applies.toList, res))
170175 }
171176
172177 /** Returns (Some(prefix) | None, rest) based on position of ':' */
@@ -177,7 +182,7 @@ class SymbolicXMLBuilder(parser: Parser, preserveWS: Boolean)(using Context) {
177182
178183 /** Various node constructions. */
179184 def group (span : Span , args : collection.Seq [Tree ]): Tree =
180- atSpan(span)( New (_scala_xml_Group, LL (makeXMLseq(span, args))) )
185+ atSpan(span)( New (_scala_xml_Group, LL (makeXMLseq(span, args, toVector = true ))) )
181186
182187 def unparsed (span : Span , str : String ): Tree =
183188 atSpan(span)( New (_scala_xml_Unparsed, LL (const(str))) )
0 commit comments