Skip to content

Commit eb23de9

Browse files
julienrfgourlaysama
authored andcommitted
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 0344e46 commit eb23de9

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

build.sbt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,15 @@ lazy val `scala-parser-combinators` = crossProject.in(file(".")).
3838
"Scala Parser Combinators",
3939
"-doc-version",
4040
version.value
41-
)
41+
),
42+
unmanagedSourceDirectories in Compile ++= {
43+
(unmanagedSourceDirectories in Compile).value.map { dir =>
44+
CrossVersion.partialVersion(scalaVersion.value) match {
45+
case Some((2, 13)) => file(dir.getPath ++ "-2.13")
46+
case _ => file(dir.getPath ++ "-2.11-2.12")
47+
}
48+
}
49+
}
4250
).
4351
jvmSettings(
4452
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"),
Lines changed: 5 additions & 0 deletions
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+
}
Lines changed: 7 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class UnitTestIO {
2525
val s = "Here is a test string"
2626
val f = io.Source.fromBytes(s.getBytes("utf-8"))
2727
val b = new collection.mutable.ArrayBuffer[Char]()
28-
f.copyToBuffer(b)
28+
b ++= f
2929
assertEquals(new String(b.toArray), s)
3030
}
3131
}

0 commit comments

Comments
 (0)