- Notifications
You must be signed in to change notification settings - Fork92
Change Node.child and Node.attribute return type to immutable.Seq on 2.13+#760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
6436666
to08e6c71
CompareIf we go ahead with this PR we'll need a new minor release (2.4.0). There is more API with return type
I'm happy take a look at those as well; I only did |
Change the type of `Node.child` and `Node.nonEmptyChildren` from`collection.Seq` to `immutable.Seq` in 2.13+.A parent is added to `Node` which defines the old signatures for`child` / `nonEmptyChildren`. This (and the resulting bridge methods)ensures binary compatbility.
For the record, there is animplicit conversion So the following works already without this PR scala>valn:Node= <a><b/></a>valn: scala.xml.Node= <a><b/></a>scala>valc: collection.immutable.Seq[Node]= n.childvalc:Seq[scala.xml.Node]=Seq(<b/>) But this fails: scala>valc: collection.immutable.Seq[String]= n.child.map(_.toString)^error:typemismatch;found :Seq[String] (in scala.collection)required:Seq[String] (in scala.collection.immutable) |
I took a closer look.
The compiler uses a |
68e70b7
to80c3a0d
Compare8631ddb
toc60701e
CompareI also changed And I changed scala>valb=newNodeBuffer()+= <b/>scala>valx:NodeSeq=Elem(null,"a",Null,TopScope,true,NodeSeq.fromSeq(b):_*)valx: scala.xml.NodeSeq= <a><b/></a>scala> b+= <c/>scala> xvalres0: scala.xml.NodeSeq= <a><b/><c/></a> I didn't change |
lrytz commentedMay 21, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This is ready, if you'd like to take a look@dubinsky. Besides mima, I also usedjardiff tocompare the changes and it looks as expected. |
retronym commentedMay 23, 2025 • edited by lrytz
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by lrytz
Uh oh!
There was an error while loading.Please reload this page.
One minor comment -- it might be more efficient to use |
Right.. We have to keep We could use a So it's probably not worth the effort... |
Agreed. If we were maximising performance from XML literals we'd be better to use an immutable ArraySeq builder with a size hint as the compiler knows how many elements there are. But maximising performance isn't really a design goal of scala-xml IMO, so the small overhead of |
c2c76c8
intoscala:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Change the type of
Node.child
/Node.nonEmptyChildren
andNode.attribute
fromcollection.Seq
toimmutable.Seq
in 2.13+.A parent is added to
Node
which defines the old signatures forchild
/nonEmptyChildren
. This (and the resulting bridge methods) ensures binary compatbility.