stevedlawrence commented on code in PR #1433:
URL: https://github.com/apache/daffodil/pull/1433#discussion_r1969765484
##########
daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SimpleTypes.scala:
##########
@@ -276,17 +276,17 @@ final class EnumerationDef(xml: Node, parentType:
SimpleTypeDefBase)
SDE("Invalid data for enumeration: %s", e.getMessage)
}
- lazy val repValuesRaw: Seq[String] = {
+ lazy val repValuesRaw: collection.Seq[String] = {
Review Comment:
Hmm, but we use `Seq` all over the place without having to specify
.collection vs .immutable. It's not clear what's different about this code?
I think maybe it's a scala-xml issue? Looking at its scaladoc,
`Node.attribute` always returns `Option[collection.Seq[NodeSeq]]`, regardless
of 2.12 vs 2.13:
[scala-xml_2.12
attribute](https://javadoc.io/static/org.scala-lang.modules/scala-xml_2.12/2.3.0/scala/xml/Node.html#attribute(uri:String,key:String):Option[Seq[scala.xml.Node]])
[scala-xml_2.13
attribute](https://javadoc.io/static/org.scala-lang.modules/scala-xml_2.13/2.3.0/scala/xml/Node.html#attribute(uri:String,key:String):Option[scala.collection.Seq[scala.xml.Node]])
So this is probably where this collection.Seq is coming from.
I imagine what we really want to do is convert that to the kind of Seq
preferred by the version of scala we are using? It looks like
`collection.toSeq` returns another `collection.Seq` on 2.12 but returns an
`immutable.Seq` on 2.13, so it seems Scala already thought of how to handle
this. So maybe this kind of code really wants to be:
```scala
val res = optNodes.map(_.toSeq).getOrElse(Seq.empty).flatMap { ... }
```
So the first thing we do is `.toSeq` to get it the right kind of Seq, and
then operate on that.
I think this suggests that anywhere `collection.Seq` shows up, we probably
want to use the `.toSeq` pattern to convert it to the kind of Seq preferred by
the version of scala we're using. Hopefully most libraries do not explicitly
return collection.Seq so this would be a fairly rare. I'm guessing it's just
scala-xml that does it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]