diff --git a/build.sbt b/build.sbt index 9e2f2ec1..349e3a64 100644 --- a/build.sbt +++ b/build.sbt @@ -67,11 +67,42 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) mimaBinaryIssueFilters ++= { import com.typesafe.tools.mima.core._ import com.typesafe.tools.mima.core.ProblemFilters._ - Seq( + Seq( // exclusions for all Scala versions // necessitated by the introduction of new abstract methods in FactoryAdapter: exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createComment"), // see #549 - exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createPCData") // see #558 + exclude[ReversedMissingMethodProblem]("scala.xml.parsing.FactoryAdapter.createPCData"), // see #558 + exclude[IncompatibleResultTypeProblem]("scala.xml.Node.NoAttributes"), + exclude[IncompatibleResultTypeProblem]("scala.xml.dtd.PublicID.attribute") + ) ++ (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, _)) => Seq( // Scala 3-specific exclusions + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.getNamespace"), + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.next"), + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.key"), + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.value"), + // not sure why `Null.value` and `Null.apply` need `DirectAbstractMethodProblem` + // exclusion for `MetaData` but `Null.key` etc. do not + exclude[DirectAbstractMethodProblem]("scala.xml.MetaData.value"), + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.remove"), + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.apply"), + exclude[DirectAbstractMethodProblem]("scala.xml.MetaData.apply"), + exclude[IncompatibleResultTypeProblem]("scala.xml.dtd.NoExternalID.publicId"), + exclude[IncompatibleResultTypeProblem]("scala.xml.dtd.NoExternalID.systemId"), + // for `SpecialNode.child: Nil.type` and `Group.child: Nothing`: + exclude[DirectAbstractMethodProblem]("scala.xml.Node.child") + ) + case Some((2, 13)) => Seq( // Scala 2.13-specific exclusions + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.filter"), + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.apply"), + exclude[DirectAbstractMethodProblem]("scala.xml.MetaData.apply") + ) + case Some((2, 12)) => Seq( // Scala 2.12-specific exclusions + exclude[IncompatibleResultTypeProblem]("scala.xml.Null.filter"), + exclude[IncompatibleResultTypeProblem] ("scala.xml.Null.apply"), + exclude[DirectAbstractMethodProblem] ("scala.xml.MetaData.apply") ) + case _ => Seq( + ) + }) }, // Mima signature checking stopped working after 3.0.2 upgrade, see #557 mimaReportSignatureProblems := (CrossVersion.partialVersion(scalaVersion.value) match { diff --git a/shared/src/main/scala/scala/xml/Group.scala b/shared/src/main/scala/scala/xml/Group.scala index 586a5981..cee67bbc 100644 --- a/shared/src/main/scala/scala/xml/Group.scala +++ b/shared/src/main/scala/scala/xml/Group.scala @@ -44,6 +44,6 @@ final case class Group(nodes: Seq[Node]) extends Node { override def label: Nothing = fail("label") override def attributes: Nothing = fail("attributes") override def namespace: Nothing = fail("namespace") - override def child /* TODO type annotation */ = fail("child") + override def child: Nothing = fail("child") def buildString(sb: StringBuilder): Nothing = fail("toString(StringBuilder)") } diff --git a/shared/src/main/scala/scala/xml/Node.scala b/shared/src/main/scala/scala/xml/Node.scala index 491f4ee9..9e54d450 100755 --- a/shared/src/main/scala/scala/xml/Node.scala +++ b/shared/src/main/scala/scala/xml/Node.scala @@ -23,12 +23,12 @@ import scala.collection.Seq */ object Node { /** the constant empty attribute sequence */ - final def NoAttributes: MetaData = Null + final def NoAttributes: Null.type = Null /** the empty namespace */ val EmptyNamespace: String = "" - def unapplySeq(n: Node) /* TODO type annotation */ = Some((n.label, n.attributes, n.child.toSeq)) + def unapplySeq(n: Node) /* TODO type annotation Some[(String, MetaData, Seq[Node])] */ = Some((n.label, n.attributes, n.child.toSeq)) } /** diff --git a/shared/src/main/scala/scala/xml/Null.scala b/shared/src/main/scala/scala/xml/Null.scala index 7e057f4f..f2bfb97f 100644 --- a/shared/src/main/scala/scala/xml/Null.scala +++ b/shared/src/main/scala/scala/xml/Null.scala @@ -27,15 +27,15 @@ case object Null extends MetaData { override def iterator: Iterator[Nothing] = Iterator.empty override def size: Int = 0 override def append(m: MetaData, scope: NamespaceBinding = TopScope): MetaData = m - override def filter(f: MetaData => Boolean): MetaData = this + override def filter(f: MetaData => Boolean): Null.type = this override def copy(next: MetaData): MetaData = next - override def getNamespace(owner: Node) /* TODO type annotation */ = null + override def getNamespace(owner: Node): scala.Null = null override def hasNext: Boolean = false - override def next /* TODO type annotation */ = null - override def key /* TODO type annotation */ = null - override def value /* TODO type annotation */ = null + override def next: scala.Null = null + override def key: scala.Null = null + override def value: scala.Null = null override def isPrefixed: Boolean = false override def length: Int = 0 @@ -47,8 +47,9 @@ case object Null extends MetaData { } override protected def basisForHashCode: Seq[Any] = Nil - override def apply(namespace: String, scope: NamespaceBinding, key: String) /* TODO type annotation */ = null - override def apply(key: String) /* TODO type annotation */ = + override def apply(namespace: String, scope: NamespaceBinding, key: String): scala.Null = null + + override def apply(key: String): scala.Null = if (Utility.isNameStart(key.head)) null else throw new IllegalArgumentException("not a valid attribute name '" + key + "', so can never match !") @@ -61,6 +62,6 @@ case object Null extends MetaData { override def wellformed(scope: NamespaceBinding): Boolean = true - override def remove(key: String) /* TODO type annotation */ = this - override def remove(namespace: String, scope: NamespaceBinding, key: String) /* TODO type annotation */ = this + override def remove(key: String): Null.type = this + override def remove(namespace: String, scope: NamespaceBinding, key: String): Null.type = this } diff --git a/shared/src/main/scala/scala/xml/SpecialNode.scala b/shared/src/main/scala/scala/xml/SpecialNode.scala index 0569bc4e..1401fefb 100644 --- a/shared/src/main/scala/scala/xml/SpecialNode.scala +++ b/shared/src/main/scala/scala/xml/SpecialNode.scala @@ -28,7 +28,7 @@ abstract class SpecialNode extends Node { final override def namespace: scala.Null = null /** always empty */ - final override def child /* TODO type annotation */ = Nil + final override def child: Nil.type = Nil /** Append string representation to the given string buffer argument. */ def buildString(sb: StringBuilder): StringBuilder diff --git a/shared/src/main/scala/scala/xml/dtd/ExternalID.scala b/shared/src/main/scala/scala/xml/dtd/ExternalID.scala index 4446a570..c1326526 100644 --- a/shared/src/main/scala/scala/xml/dtd/ExternalID.scala +++ b/shared/src/main/scala/scala/xml/dtd/ExternalID.scala @@ -73,7 +73,7 @@ case class PublicID(override val publicId: String, override val systemId: String def label: String = "#PI" /** always empty */ - def attribute: MetaData = Node.NoAttributes + def attribute: Null.type = Node.NoAttributes /** always empty */ def child: Nil.type = Nil @@ -85,8 +85,8 @@ case class PublicID(override val publicId: String, override val systemId: String * @author Michael Bayne */ object NoExternalID extends ExternalID { - override val publicId /* TODO type annotation */ = null - override val systemId /* TODO type annotation */ = null + override val publicId: scala.Null = null + override val systemId: scala.Null = null override def toString: String = "" }