From ee3212d1c2d89c76b0b0859ab83578cd4c5237a6 Mon Sep 17 00:00:00 2001 From: Leonid Dubinsky Date: Tue, 28 Mar 2023 14:46:18 -0400 Subject: [PATCH] Add missing type annotations that do not break binary compatibility Some missing type annotations can be added without breaking binary compatibility; they are added in this pull request, letting #655 concentrate on adding type annotations that _do_ break binary compatibility (for Scala 3). Removed MiMa exclusions that are no longer needed. Removed Gitter link to a non-existing room. Added links to the compiler implementation of the `SymbolicXMLBuilder` for different versions of Scala. --- README.md | 9 +++++++-- build.sbt | 8 -------- .../scala-2.13-/scala/xml/ScalaVersionSpecific.scala | 8 ++++---- shared/src/main/scala/scala/xml/Null.scala | 2 +- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 10f310d2..6cd3fe41 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,17 @@ scala-xml [![latest release for 2.12](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.12.svg?label=scala+2.12)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.12) [![latest release for 2.13](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.13.svg?label=scala+2.13)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.13) [![latest release for 3.0](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_3.svg?label=scala+3)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_3) -[![Gitter](https://badges.gitter.im/Join+Chat.svg)](https://gitter.im/scala/scala-xml) ========= The standard Scala XML library. Please file XML issues here, not at https://github.com/scala/bug/issues or http://github.com/lampepfl/dotty/issues. -The decoupling of scala-xml from the Scala compiler and standard library is possible because the compiler desugars XML literals in Scala source code into a set of method calls. Alternative implementations of these calls are welcome! (This [implementation](https://github.com/scala/scala/blob/2.11.x/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala) shows the calls needed.) +The decoupling of scala-xml from the Scala compiler and standard library is possible because the compiler desugars XML literals in Scala source code into a set of method calls. +Alternative implementations of these calls are welcome! +Compiler code that shows the calls needed: + [Scala 2.11](https://github.com/scala/scala/blob/2.11.x/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala), + [Scala 2.12](https://github.com/scala/scala/blob/2.12.x/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala), + [Scala 2.13](https://github.com/scala/scala/blob/2.13.x/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala), + [Scala 3](https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/parsing/xml/SymbolicXMLBuilder.scala). API documentation is available [here](https://javadoc.io/doc/org.scala-lang.modules/scala-xml_2.13/). diff --git a/build.sbt b/build.sbt index 4814321e..257bc67f 100644 --- a/build.sbt +++ b/build.sbt @@ -68,14 +68,6 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform, NativePlatform) import com.typesafe.tools.mima.core._ import com.typesafe.tools.mima.core.ProblemFilters._ Seq( - // afaict this is just a JDK 8 vs 16 difference, producing a false positive when - // we compare classes built on JDK 16 (which we only do on CI, not at release time) - // to previous-version artifacts that were built on 8. see scala/scala-xml#501 - exclude[DirectMissingMethodProblem]("scala.xml.include.sax.XIncluder.declaration"), - - // necessitated by the switch from DefaultHandler to DefaultHandler2 in FactoryAdapter: - exclude[MissingTypesProblem]("scala.xml.parsing.FactoryAdapter"), // see #549 - // 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 diff --git a/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala b/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala index a8256f0c..35d6d0e2 100644 --- a/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala +++ b/shared/src/main/scala-2.13-/scala/xml/ScalaVersionSpecific.scala @@ -12,21 +12,21 @@ package scala.xml -import scala.collection.SeqLike +import scala.collection.{SeqLike, mutable} import scala.collection.generic.CanBuildFrom private[xml] object ScalaVersionSpecific { import NodeSeq.Coll type CBF[-From, -A, +C] = CanBuildFrom[From, A, C] object NodeSeqCBF extends CanBuildFrom[Coll, Node, NodeSeq] { - override def apply(from: Coll) /* TODO type annotation */ = NodeSeq.newBuilder - override def apply() /* TODO type annotation */ = NodeSeq.newBuilder + override def apply(from: Coll): mutable.Builder[Node, NodeSeq] = NodeSeq.newBuilder + override def apply(): mutable.Builder[Node, NodeSeq] = NodeSeq.newBuilder } } private[xml] trait ScalaVersionSpecificNodeSeq extends SeqLike[Node, NodeSeq] { self: NodeSeq => /** Creates a list buffer as builder for this class */ - override protected[this] def newBuilder /* TODO type annotation */ = NodeSeq.newBuilder + override protected[this] def newBuilder: mutable.Builder[Node, NodeSeq] = NodeSeq.newBuilder } private[xml] trait ScalaVersionSpecificNodeBuffer { self: NodeBuffer => diff --git a/shared/src/main/scala/scala/xml/Null.scala b/shared/src/main/scala/scala/xml/Null.scala index 778da1a6..7e057f4f 100644 --- a/shared/src/main/scala/scala/xml/Null.scala +++ b/shared/src/main/scala/scala/xml/Null.scala @@ -24,7 +24,7 @@ import scala.collection.Seq * @author Burak Emir */ case object Null extends MetaData { - override def iterator /* TODO type annotation */ = Iterator.empty + 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