summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/library/scala/xml/Utility.scala2
-rw-r--r--test/files/run/t7074.check9
-rw-r--r--test/files/run/t7074.scala15
3 files changed, 25 insertions, 1 deletions
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala
index 9429e9caa7..030a89773e 100755
--- a/src/library/scala/xml/Utility.scala
+++ b/src/library/scala/xml/Utility.scala
@@ -64,7 +64,7 @@ object Utility extends AnyRef with parsing.TokenTests {
val key = md.key
val smaller = sort(md.filter { m => m.key < key })
val greater = sort(md.filter { m => m.key > key })
- smaller.copy(md.copy ( greater ))
+ smaller.foldRight (md copy greater) ((x, xs) => x copy xs)
}
/** Return the node with its attribute list sorted alphabetically
diff --git a/test/files/run/t7074.check b/test/files/run/t7074.check
new file mode 100644
index 0000000000..ab9cf11f16
--- /dev/null
+++ b/test/files/run/t7074.check
@@ -0,0 +1,9 @@
+<a/>
+<a b="2" c="3" d="1"/>
+<a b="2" c="4" d="1" e="3" f="5"/>
+<a b="5" c="4" d="3" e="2" f="1"/>
+<a b="1" c="2" d="3" e="4" f="5"/>
+<a a:b="2" a:c="3" a:d="1"/>
+<a a:b="2" a:c="4" a:d="1" a:e="3" a:f="5"/>
+<a a:b="5" a:c="4" a:d="3" a:e="2" a:f="1"/>
+<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>
diff --git a/test/files/run/t7074.scala b/test/files/run/t7074.scala
new file mode 100644
index 0000000000..693a076a7a
--- /dev/null
+++ b/test/files/run/t7074.scala
@@ -0,0 +1,15 @@
+import scala.xml.Utility.sort
+
+object Test extends App {
+ println(sort(<a/>))
+ println(sort(<a d="1" b="2" c="3"/>))
+ println(sort(<a d="1" b="2" e="3" c="4" f="5"/>))
+ println(sort(<a f="1" e="2" d="3" c="4" b="5"/>))
+ println(sort(<a b="1" c="2" d="3" e="4" f="5"/>))
+
+ println(sort(<a a:d="1" a:b="2" a:c="3"/>))
+ println(sort(<a a:d="1" a:b="2" a:e="3" a:c="4" a:f="5"/>))
+ println(sort(<a a:f="1" a:e="2" a:d="3" a:c="4" a:b="5"/>))
+ println(sort(<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>))
+}
+