Skip to content

Commit d04f3c3

Browse files
committed
Ensure conversion to imm.Seq is only done once
1 parent 1399695 commit d04f3c3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

shared/src/main/scala/scala/xml/Group.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ import scala.collection.Seq
2222
*/
2323
// Note: used by the Scala compiler.
2424
final case class Group(nodes: Seq[Node]) extends Node {
25+
// Ideally, the `immutable.Seq` would be stored as a field.
26+
// But evolving the case class and remaining binary compatible is very difficult
27+
// Since `Group` is used rarely, call `toSeq` on the field.
28+
// In practice, it should not matter - the `nodes` field anyway contains an `immutable.Seq`.
2529
override def theSeq: ScalaVersionSpecific.SeqOfNode = nodes.toSeq
2630

2731
override def canEqual(other: Any): Boolean = other match {

shared/src/main/scala/scala/xml/NodeSeq.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import scala.collection.Seq
2626
object NodeSeq {
2727
final val Empty: NodeSeq = fromSeq(Nil)
2828
def fromSeq(s: Seq[Node]): NodeSeq = new NodeSeq {
29-
override def theSeq: ScalaVersionSpecific.SeqOfNode = s match {
29+
override val theSeq: ScalaVersionSpecific.SeqOfNode = s match {
3030
case ns: ScalaVersionSpecific.SeqOfNode => ns
3131
case _ => s.toVector
3232
}

0 commit comments

Comments
 (0)