@@ -2,18 +2,12 @@ object Test {
22 import scala .xml .*
33 def main (args : Array [String ]): Unit = {
44
5- val singleQuotedTextCase = if (true ) {
5+ val xml = if (true ) {
66 <script type =" text/javascript" >
77 ' location .reload()'
88 ' foo bar'
99 </script >
1010 } else <div >empty</div >
11-
12- val casePatMatch = for (case t @ <foo >FooBar </foo > <- Seq (xml))
13- yield t
14- // TODO: This fails
15- val casePatMatchWithCond = for (case t @ <foo >FooBar </foo > if true <- Seq (xml))
16- yield t
1711
1812 assert(
1913 xml match
@@ -26,7 +20,47 @@ object Test {
2620 ,
2721 xml
2822 )
23+ // Scala 3 syntax
24+ val auxiliary0 = if true then {
25+ <script type =" text/javascript" >
26+ ' location .reload()'
27+ ' foo bar'
28+ </script >
29+ } else <div >empty</div >
30+
31+ val auxiliary1 = if true then
32+ <script type =" text/javascript" >
33+ ' location .reload()'
34+ ' foo bar'
35+ </script >
36+ else <div >empty</div >
37+
38+ val auxiliary2 = if true then <div >A </div >else <div >B </div >
39+
40+ // Note:
41+ // This does not pass in Scala 2.12.18 and 2.13.12
42+ // due to "Sequence argument type annotation `: _*` cannot be used here:"
43+ val auxiliary3 = if (true ) <div >A </div >else <div >B </div >
44+
45+ // Note: This passes in Scala 2.12.18 and 2.13.12 too.
46+ val auxiliary4 = if (true ) <div attr =" ..." >A </div >else <div attr =" ..." >B </div >
47+
48+ // Pattern match without guard.
49+ // Note: This passes in Scala 2.12.18 and 2.13.12 too.
50+ val auxiliary5 = for (case _ @ <div >empty</div > <- Seq (xml)) yield ()
51+ // Note: These pass in Scala 2.12.18 and 2.13.12.
52+ val auxiliary6 = for (case _ @ <div >empty</div ><- Seq (xml)) yield ()
53+ val auxiliary7 = for (case _ @ <div >empty</div ><- Seq (xml)) yield ()
54+ // Pattern match with if guard.
55+ // Note: This passes in Scala 2.12.18 and 2.13.12 too.
56+ val auxiliary8 = for (case _ @ <foo >FooBar </foo > <- Seq (xml) if true )
57+ // Note: These pass in Scala 2.12.18 and 2.13.12.
58+ val auxiliary9 = for (case _ @ <foo >FooBar </foo ><- Seq (xml) if true )
59+ val auxiliary10 = for (case _ @ <foo >FooBar </foo ><- Seq (xml) if true )
60+ yield ()
61+
2962 }
63+
3064}
3165
3266package scala .xml {
@@ -46,10 +80,7 @@ package scala.xml {
4680 def child : Seq [Node ]
4781 override def toString = label + child.mkString
4882 }
49- class Comment (commentText : String ) extends Node {
50- def label = commentText
51- def child = Nil
52- }
83+
5384 class Elem (prefix : String , val label : String , attributes1 : MetaData , scope : NamespaceBinding , minimizeEmpty : Boolean , val child : Node * ) extends Node
5485 object Elem {
5586 def unapply (e: Elem ): Option [(String ,String ,Any ,Text ,Any )] = Some ((" dummy" ," dummy" ,null ,null ,null ))
0 commit comments