Skip to content

Add missing type annotations that do not break binary compatibility #657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

Expand Down
8 changes: 0 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
2 changes: 1 addition & 1 deletion shared/src/main/scala/scala/xml/Null.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down