From 32fde82fb58df3686af50c272d113f31f07a60d9 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Mon, 28 May 2012 12:51:05 +0200 Subject: fix t5843 --- src/library/scala/xml/Attribute.scala | 4 ++-- test/files/run/t5843.check | 9 +++++++++ test/files/run/t5843.scala | 15 +++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/files/run/t5843.check create mode 100644 test/files/run/t5843.scala diff --git a/src/library/scala/xml/Attribute.scala b/src/library/scala/xml/Attribute.scala index 6b68e97412..4c50b15e53 100644 --- a/src/library/scala/xml/Attribute.scala +++ b/src/library/scala/xml/Attribute.scala @@ -61,8 +61,8 @@ abstract trait Attribute extends MetaData { else copy(next remove key) def remove(namespace: String, scope: NamespaceBinding, key: String) = - if (isPrefixed && this.key == key && (scope getURI pre) == namespace) next - else next.remove(namespace, scope, key) + if (this.key == key && (scope getURI pre) == namespace) next + else copy(next.remove(namespace, scope, key)) def isPrefixed: Boolean = pre != null diff --git a/test/files/run/t5843.check b/test/files/run/t5843.check new file mode 100644 index 0000000000..2bf97f4cdb --- /dev/null +++ b/test/files/run/t5843.check @@ -0,0 +1,9 @@ + foo="1" + bar="2" foo="1" +null + bar="2" + foo="1" + bar="2" + foo="1" + bar="2" foo="1" + bar="2" foo="1" diff --git a/test/files/run/t5843.scala b/test/files/run/t5843.scala new file mode 100644 index 0000000000..43d588c7b7 --- /dev/null +++ b/test/files/run/t5843.scala @@ -0,0 +1,15 @@ +object Test extends App { + val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null) + val bar = scala.xml.Attribute(null, "bar", "2", foo) + println(foo) + println(bar) + println(scala.xml.TopScope.getURI(foo.pre)) + println(bar remove "foo") + println(bar remove "bar") + println(bar remove (null, scala.xml.TopScope, "foo")) + println(bar remove (null, scala.xml.TopScope, "bar")) + + val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope) + println(bar remove (null, ns, "foo")) + println(bar remove (null, ns, "bar")) +} -- cgit v1.2.3