Skip to content

Move to Scala 2.13.0-M4 #222

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

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jdk:
scala:
- 2.11.12
- 2.12.6
- 2.13.0-M3
- 2.13.0-M4

env:
global:
Expand All @@ -30,13 +30,13 @@ env:

matrix:
exclude:
- scala: 2.13.0-M3
- scala: 2.13.0-M4
env: SCALAJS_VERSION=1.0.0-M3
- jdk: oraclejdk9
env: SCALAJS_VERSION=1.0.0-M3
- scala: 2.12.6
jdk: openjdk6
- scala: 2.13.0-M3
- scala: 2.13.0-M4
jdk: openjdk6

script: admin/build.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ scala-xml
[![Travis](https://img.shields.io/travis/scala/scala-xml.svg)](https://travis-ci.org/scala/scala-xml)
[![latest release for 2.11](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.11.svg?label=scala+2.11)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.11)
[![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.0-M3](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.13.0-M3.svg?label=scala+2.13.0-M3)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.13.0-M3)
[![latest release for 2.13.0-M4](https://img.shields.io/maven-central/v/org.scala-lang.modules/scala-xml_2.13.0-M4.svg?label=scala+2.13.0-M4)](http://mvnrepository.com/artifact/org.scala-lang.modules/scala-xml_2.13.0-M4)
[![Gitter](https://badges.gitter.im/Join+Chat.svg)](https://gitter.im/scala/scala-xml)
=========

Expand Down
12 changes: 11 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sbtcrossproject.{crossProject, CrossType}
import ScalaModulePlugin._

crossScalaVersions in ThisBuild := List("2.12.6", "2.11.12", "2.13.0-M3")
crossScalaVersions in ThisBuild := List("2.12.6", "2.11.12", "2.13.0-M4")

lazy val xml = crossProject(JSPlatform, JVMPlatform)
.withoutSuffixFor(JVMPlatform)
Expand All @@ -23,6 +23,16 @@ lazy val xml = crossProject(JSPlatform, JVMPlatform)
else Some("1.1.0")
},

unmanagedSourceDirectories in Compile ++= {
(unmanagedSourceDirectories in Compile).value.map { dir =>
val sv = scalaVersion.value
CrossVersion.partialVersion(sv) match {
case Some((2, 13)) => file(dir.getPath ++ "-2.13")
case _ => file(dir.getPath ++ "-2.11-2.12")
}
}
},

apiMappings ++= Map(
scalaInstance.value.libraryJar
-> url(s"http://www.scala-lang.org/api/${scalaVersion.value}/")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package scala.xml

import scala.collection.SeqLike
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] {
def apply(from: Coll) = NodeSeq.newBuilder
def apply() = 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 = NodeSeq.newBuilder
}

private[xml] trait ScalaVersionSpecificNodeBuffer { self: NodeBuffer =>
override def stringPrefix: String = "NodeBuffer"
}
26 changes: 26 additions & 0 deletions shared/src/main/scala-2.13/scala/xml/ScalaVersionSpecific.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package scala.xml

import scala.collection.immutable.StrictOptimizedSeqOps
import scala.collection.{SeqOps, immutable, mutable}
import scala.collection.BuildFrom
import scala.collection.mutable.Builder

private[xml] object ScalaVersionSpecific {
import NodeSeq.Coll
type CBF[-From, -A, +C] = BuildFrom[From, A, C]
object NodeSeqCBF extends BuildFrom[Coll, Node, NodeSeq] {
def newBuilder(from: Coll): Builder[Node, NodeSeq] = NodeSeq.newBuilder
def fromSpecificIterable(from: Coll)(it: Iterable[Node]): NodeSeq = (NodeSeq.newBuilder ++= from).result()
}
}

private[xml] trait ScalaVersionSpecificNodeSeq
extends SeqOps[Node, immutable.Seq, NodeSeq]
with StrictOptimizedSeqOps[Node, immutable.Seq, NodeSeq] { self: NodeSeq =>
override def fromSpecificIterable(coll: Iterable[Node]): NodeSeq = (NodeSeq.newBuilder ++= coll).result()
override def newSpecificBuilder: mutable.Builder[Node, NodeSeq] = NodeSeq.newBuilder
}

private[xml] trait ScalaVersionSpecificNodeBuffer { self: NodeBuffer =>
override def className: String = "NodeBuffer"
}
5 changes: 1 addition & 4 deletions shared/src/main/scala/scala/xml/NodeBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ package xml
*
* @author Burak Emir
*/
class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] {

override def stringPrefix: String = "NodeBuffer"

class NodeBuffer extends scala.collection.mutable.ArrayBuffer[Node] with ScalaVersionSpecificNodeBuffer {
/**
* Append given object to this buffer, returns reference on this
* `NodeBuffer` for convenience. Some rules apply:
Expand Down
23 changes: 11 additions & 12 deletions shared/src/main/scala/scala/xml/NodeSeq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
package scala
package xml

import scala.collection.{ mutable, immutable, generic, SeqLike, AbstractSeq }
import scala.collection.{ mutable, immutable, AbstractSeq }
import mutable.{ Builder, ListBuffer }
import generic.{ CanBuildFrom }
import ScalaVersionSpecific.CBF
import scala.language.implicitConversions
import scala.collection.Seq

Expand All @@ -25,12 +25,15 @@ object NodeSeq {
def fromSeq(s: Seq[Node]): NodeSeq = new NodeSeq {
def theSeq = s
}

// ---
// For 2.11 / 2.12 only. Moving the implicit to a parent trait of `object NodeSeq` and keeping it
// in ScalaVersionSpecific doesn't work because the implicit becomes less specific, which leads to
// ambiguities.
type Coll = NodeSeq
implicit def canBuildFrom: CanBuildFrom[Coll, Node, NodeSeq] =
new CanBuildFrom[Coll, Node, NodeSeq] {
def apply(from: Coll) = newBuilder
def apply() = newBuilder
}
implicit def canBuildFrom: CBF[Coll, Node, NodeSeq] = ScalaVersionSpecific.NodeSeqCBF
// ---

def newBuilder: Builder[Node, NodeSeq] = new ListBuffer[Node] mapResult fromSeq
implicit def seqToNodeSeq(s: Seq[Node]): NodeSeq = fromSeq(s)
}
Expand All @@ -41,11 +44,7 @@ object NodeSeq {
*
* @author Burak Emir
*/
abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with SeqLike[Node, NodeSeq] with Equality with Serializable {

/** Creates a list buffer as builder for this class */
override protected[this] def newBuilder = NodeSeq.newBuilder

abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with ScalaVersionSpecificNodeSeq with Equality with Serializable {
def theSeq: Seq[Node]
def length = theSeq.length
override def iterator = theSeq.iterator
Expand Down