Skip to content

Commit

Permalink
Merge pull request #704 from xuwei-k/new-wildcard-syntax
Browse files Browse the repository at this point in the history
use new wildcard syntax
  • Loading branch information
dubinsky authored Jan 3, 2024
2 parents 2e0d1bb + a5eecfe commit ccec3ca
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion jvm/src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class XMLTestJVM {

@UnitTest
def t5115(): Unit = {
def assertHonorsIterableContract(i: Iterable[_]): Unit = assertEquals(i.size.toLong, i.iterator.size.toLong)
def assertHonorsIterableContract(i: Iterable[?]): Unit = assertEquals(i.size.toLong, i.iterator.size.toLong)

assertHonorsIterableContract(<a/>.attributes)
assertHonorsIterableContract(<a x=""/>.attributes)
Expand Down
4 changes: 2 additions & 2 deletions shared/src/main/scala/scala/xml/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class Atom[+A](val data: A) extends SpecialNode with Serializable {
override protected def basisForHashCode: Seq[Any] = Seq(data)

override def strict_==(other: Equality): Boolean = other match {
case x: Atom[_] => data == x.data
case x: Atom[?] => data == x.data
case _ => false
}

override def canEqual(other: Any): Boolean = other match {
case _: Atom[_] => true
case _: Atom[?] => true
case _ => false
}

Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/Equality.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object Equality {
* Note - these functions assume strict equality has already failed.
*/
def compareBlithely(x1: AnyRef, x2: String): Boolean = x1 match {
case x: Atom[_] => x.data == x2
case x: Atom[?] => x.data == x2
case x: NodeSeq => x.text == x2
case _ => false
}
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ abstract class Node extends NodeSeq {
/**
* used internally. Atom/Molecule = -1 PI = -2 Comment = -3 EntityRef = -5
*/
def isAtom: Boolean = this.isInstanceOf[Atom[_]]
def isAtom: Boolean = this.isInstanceOf[Atom[?]]

/** The logic formerly found in typeTag$, as best I could infer it. */
def doCollectNamespaces: Boolean = true // if (tag >= 0) DO collect namespaces
Expand Down
6 changes: 3 additions & 3 deletions shared/src/main/scala/scala/xml/NodeBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] with ScalaVe
def &+(o: Any): NodeBuffer = {
o match {
case null | _: Unit | Text("") => // ignore
case it: Iterator[_] => it.foreach(&+)
case it: Iterator[?] => it.foreach(&+)
case n: Node => super.+=(n)
case ns: Iterable[_] => this &+ ns.iterator
case ns: Array[_] => this &+ ns.iterator
case ns: Iterable[?] => this &+ ns.iterator
case ns: Array[?] => this &+ ns.iterator
case d => super.+=(new Atom(d))
}
this
Expand Down
4 changes: 2 additions & 2 deletions shared/src/main/scala/scala/xml/PrettyPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class PrettyPrinter(width: Int, step: Int, minimizeEmpty: Boolean) {

protected def childrenAreLeaves(n: Node): Boolean = {
def isLeaf(l: Node): Boolean = l match {
case _: Atom[_] | _: Comment | _: EntityRef | _: ProcInstr => true
case _: Atom[?] | _: Comment | _: EntityRef | _: ProcInstr => true
case _ => false
}
n.child.forall(isLeaf)
Expand All @@ -152,7 +152,7 @@ class PrettyPrinter(width: Int, step: Int, minimizeEmpty: Boolean) {

case Text(s) if s.trim.isEmpty =>

case _: Atom[_] | _: Comment | _: EntityRef | _: ProcInstr =>
case _: Atom[?] | _: Comment | _: EntityRef | _: ProcInstr =>
makeBox(ind, node.toString.trim)
case Group(xs) =>
traverse(xs.iterator, pscope, ind)
Expand Down
2 changes: 1 addition & 1 deletion shared/src/test/scala/scala/xml/PatternMatchingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PatternMatchingTest {

object SafeNodeSeq {
def unapplySeq(any: Any): Option[Seq[Node]] = any match {
case s: Seq[_] => Some(s.flatMap {
case s: Seq[?] => Some(s.flatMap {
case n: Node => n
case _ => NodeSeq.Empty
})
Expand Down
2 changes: 1 addition & 1 deletion shared/src/test/scala/scala/xml/XMLTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ Ours is the portal of hope, come as you are."

@UnitTest
def t5115(): Unit = {
def assertHonorsIterableContract(i: Iterable[_]): Unit = assertEquals(i.size.toLong, i.iterator.size.toLong)
def assertHonorsIterableContract(i: Iterable[?]): Unit = assertEquals(i.size.toLong, i.iterator.size.toLong)

assertHonorsIterableContract(<a/>.attributes)
assertHonorsIterableContract(<a x=""/>.attributes)
Expand Down

0 comments on commit ccec3ca

Please sign in to comment.