Skip to content

Commit bc39da6

Browse files
committed
Cross compatibility with the new collections of 2.13
Use distinct implementations of PagedSeq according to the scala version. Use JavaConverters rather than JavaConversions. Use ++= instead of copyToBuffer.
1 parent dba66f0 commit bc39da6

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

build.sbt

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ lazy val `scala-parser-combinators` = crossProject.in(file(".")).
4040
"Scala Parser Combinators",
4141
"-doc-version",
4242
version.value
43-
)
43+
),
44+
unmanagedSourceDirectories in Compile ++= {
45+
(unmanagedSourceDirectories in Compile).value.map { dir =>
46+
CrossVersion.partialVersion(scalaVersion.value) match {
47+
case Some((2, 13)) => file(dir.getPath ++ "-2.13")
48+
case _ => file(dir.getPath ++ "-2.11-2.12")
49+
}
50+
}
51+
}
4452
).
4553
jvmSettings(
4654
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"),

jvm/src/test/scala/scala/util/parsing/combinator/t4929.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.util.parsing.json._
22
import java.util.concurrent._
3-
import collection.JavaConversions._
3+
import collection.JavaConverters._
44

55
import org.junit.Test
66

@@ -36,6 +36,6 @@ class t4929 {
3636
thread.setDaemon(true)
3737
thread.start()
3838
}
39-
errors foreach { throw(_) }
39+
errors.asScala foreach { throw(_) }
4040
}
4141
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package scala.util.parsing.input
2+
3+
private[input] trait ScalaVersionSpecificPagedSeq[T] {
4+
// Nothing for 2.11 and 2.12!
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package scala.util.parsing.input
2+
3+
private[input] trait ScalaVersionSpecificPagedSeq[T] { self: PagedSeq[T] =>
4+
// Members declared in scala.collection.Seq
5+
override def iterableFactory: collection.SeqFactory[collection.IndexedSeq] = collection.IndexedSeq
6+
7+
}

shared/src/main/scala/scala/util/parsing/input/PagedSeq.scala

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class PagedSeq[T: ClassTag] protected(
129129
end: Int)
130130
extends scala.collection.AbstractSeq[T]
131131
with scala.collection.IndexedSeq[T]
132+
with ScalaVersionSpecificPagedSeq[T]
132133
{
133134
def this(more: (Array[T], Int, Int) => Int) = this(more, new Page[T](0), 0, UndeterminedEnd)
134135

shared/src/test/scala/scala/util/parsing/combinator/UnitTestIO.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class UnitTestIO {
2626
val s = "Here is a test string"
2727
val f = io.Source.fromBytes(s.getBytes("utf-8"))
2828
val b = new collection.mutable.ArrayBuffer[Char]()
29-
f.copyToBuffer(b)
29+
b ++= f
3030
assertEquals(new String(b.toArray), s)
3131
}
3232
}

0 commit comments

Comments
 (0)