-
Notifications
You must be signed in to change notification settings - Fork 407
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
Changes to compile with Scala 2.13.0-M4 #411
Changes from 7 commits
6611977
b64e21f
4b253fb
fd6aa84
5ba8ddf
1c79131
543b405
f7d6cf8
12c8a66
4848ee8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
sourceDirectory := file("dummy source directory") | ||
|
||
val scalaMajorVersion = SettingKey[Int]("scalaMajorVersion") | ||
|
||
scalaVersionSettings | ||
|
||
lazy val versionNumber = "1.14.1" | ||
|
@@ -10,7 +12,13 @@ lazy val travisCommit = Option(System.getenv().get("TRAVIS_COMMIT")) | |
|
||
lazy val scalaVersionSettings = Seq( | ||
scalaVersion := "2.12.6", | ||
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.13.0-M3", scalaVersion.value) | ||
crossScalaVersions := Seq("2.10.7", "2.11.12", "2.13.0-M4", scalaVersion.value), | ||
scalaMajorVersion := { | ||
val v = scalaVersion.value | ||
CrossVersion.partialVersion(v).map(_._2.toInt).getOrElse { | ||
throw new RuntimeException(s"could not get Scala major version from $v") | ||
} | ||
} | ||
) | ||
|
||
lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq( | ||
|
@@ -43,6 +51,11 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq( | |
|
||
unmanagedSourceDirectories in Compile += (baseDirectory in LocalRootProject).value / "src" / "main" / "scala", | ||
|
||
unmanagedSourceDirectories in Compile += { | ||
val s = if (scalaMajorVersion.value >= 13) "+" else "-" | ||
(baseDirectory in LocalRootProject).value / "src" / "main" / s"scala-2.13$s" | ||
}, | ||
|
||
unmanagedSourceDirectories in Test += (baseDirectory in LocalRootProject).value / "src" / "test" / "scala", | ||
|
||
resolvers += "sonatype" at "https://oss.sonatype.org/content/repositories/releases", | ||
|
@@ -54,18 +67,18 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq( | |
"-encoding", "UTF-8", | ||
"-feature", | ||
"-unchecked", | ||
"-Xfatal-warnings", | ||
"-Xfuture", | ||
"-Yno-adapted-args", | ||
"-Ywarn-dead-code", | ||
"-Ywarn-inaccessible", | ||
"-Ywarn-nullary-override", | ||
"-Ywarn-nullary-unit", | ||
"-Ywarn-numeric-widen") ++ { | ||
scalaBinaryVersion.value match { | ||
case "2.10" => Seq("-Xlint") | ||
case "2.11" => Seq("-Xlint", "-Ywarn-infer-any", "-Ywarn-unused-import") | ||
case _ => Seq("-Xlint:-unused", "-Ywarn-infer-any", "-Ywarn-unused-import", "-Ywarn-unused:-patvars,-implicits,-locals,-privates,-explicits") | ||
val modern = Seq("-Xlint:-unused", "-Ywarn-infer-any", "-Ywarn-unused-import", "-Ywarn-unused:-patvars,-implicits,-locals,-privates,-explicits") | ||
scalaMajorVersion.value match { | ||
case 10 => Seq("-Xfatal-warnings", "-Xlint") | ||
case 11 => Seq("-Xfatal-warnings", "-Xlint", "-Ywarn-infer-any", "-Ywarn-unused-import") | ||
case 12 => "-Xfatal-warnings" +: modern | ||
case 13 => modern | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it mean 2.13 enables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No :-) this disables fatal warnings on 2.13 because there are some deprecation warnings due to cross-building (usage of Stream) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. got it, one alternative way could be to add silencer for that particular place instead of disabling it in general, but I guess it's not a big deal, as it's enabled for the rest of versions |
||
} | ||
}, | ||
|
||
|
@@ -78,7 +91,11 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq( | |
// don't use fatal warnings in tests | ||
scalacOptions in Test ~= (_ filterNot (_ == "-Xfatal-warnings")), | ||
|
||
mimaPreviousArtifacts := Set("org.scalacheck" %% "scalacheck" % "1.14.0"), | ||
mimaPreviousArtifacts := { | ||
// TODO: re-enable MiMa for 2.13.0-M4 once there is a release out | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a ticket to keep track of this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment #410 (comment) |
||
if (scalaMajorVersion.value == 13) Set() | ||
else Set("org.scalacheck" %% "scalacheck" % "1.14.0") | ||
}, | ||
|
||
publishTo := { | ||
val nexus = "https://oss.sonatype.org/" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*-------------------------------------------------------------------------*\ | ||
** ScalaCheck ** | ||
** Copyright (c) 2007-2018 Rickard Nilsson. All rights reserved. ** | ||
** http://www.scalacheck.org ** | ||
** ** | ||
** This software is released under the terms of the Revised BSD License. ** | ||
** There is NO WARRANTY. See the file LICENSE for the full text. ** | ||
\*------------------------------------------------------------------------ */ | ||
|
||
package org.scalacheck | ||
|
||
import rng.Seed | ||
|
||
private[scalacheck] object ScalaVersionSpecific { | ||
def toLazyList[T](i: IterableOnce[T]) = LazyList.from(i) | ||
} | ||
|
||
private[scalacheck] trait GenVersionSpecific { | ||
|
||
/** Generates an infinite lazy list. */ | ||
def infiniteLazyList[T](g: => Gen[T]): Gen[LazyList[T]] = { | ||
def unfold[A, S](z: S)(f: S => Option[(A, S)]): LazyList[A] = f(z) match { | ||
case Some((h, s)) => h #:: unfold(s)(f) | ||
case None => LazyList.empty | ||
} | ||
Gen.gen { (p, seed0) => | ||
new Gen.R[LazyList[T]] { | ||
val result: Option[LazyList[T]] = Some(unfold(seed0)(s => Some(g.pureApply(p, s) -> s.next))) | ||
val seed: Seed = seed0.next | ||
} | ||
} | ||
} | ||
} | ||
|
||
private[scalacheck] trait GenSpecificationVersionSpecific | ||
|
||
private[scalacheck] trait CogenVersionSpecific { | ||
implicit def cogenLazyList[A: Cogen]: Cogen[LazyList[A]] = | ||
Cogen.it(_.iterator) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*-------------------------------------------------------------------------*\ | ||
** ScalaCheck ** | ||
** Copyright (c) 2007-2018 Rickard Nilsson. All rights reserved. ** | ||
** http://www.scalacheck.org ** | ||
** ** | ||
** This software is released under the terms of the Revised BSD License. ** | ||
** There is NO WARRANTY. See the file LICENSE for the full text. ** | ||
\*------------------------------------------------------------------------ */ | ||
|
||
package org.scalacheck.util | ||
|
||
import java.util.ArrayList | ||
|
||
import collection.{Map => _, _} | ||
import scala.collection.mutable.Builder | ||
|
||
|
||
private[util] trait BuildableVersionSpecific { | ||
implicit def buildableFactory[T,C](implicit f: Factory[T,C]) = | ||
new Buildable[T,C] { | ||
def builder = f.newBuilder | ||
} | ||
} | ||
|
||
private[util] class ArrayListBuilder[T] extends Builder[T, ArrayList[T]] { | ||
private val al = new ArrayList[T] | ||
def addOne(x: T): this.type = { | ||
al.add(x) | ||
this | ||
} | ||
def clear(): Unit = al.clear() | ||
def result(): ArrayList[T] = al | ||
} | ||
|
||
/** | ||
* Factory instances implementing Serializable, so that the objects capturing those can be | ||
* serializable too. | ||
*/ | ||
// Named `...CanBuildFroms` for 2.12 source compatibility (`import SerializableCanBuildFroms._`) | ||
// Can be renamed to `SerializableFactories` in a major release. | ||
object SerializableCanBuildFroms { | ||
implicit def listFactory[T]: Factory[T, List[T]] = | ||
new Factory[T, List[T]] with Serializable { | ||
def fromSpecific(source: IterableOnce[T]): List[T] = List.from(source) | ||
def newBuilder: Builder[T, List[T]] = List.newBuilder[T] | ||
} | ||
|
||
implicit def bitsetFactory[T]: Factory[Int, BitSet] = | ||
new Factory[Int, BitSet] with Serializable { | ||
def fromSpecific(source: IterableOnce[Int]) = BitSet.fromSpecific(source) | ||
def newBuilder: Builder[Int, BitSet] = BitSet.newBuilder | ||
} | ||
|
||
implicit def mapFactory[T, U]: Factory[(T, U), Map[T, U]] = | ||
new Factory[(T, U), Map[T, U]] with Serializable { | ||
def fromSpecific(source: IterableOnce[(T, U)]) = Map.from(source) | ||
def newBuilder: Builder[(T, U), Map[T, U]] = Map.newBuilder[T, U] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/*-------------------------------------------------------------------------*\ | ||
** ScalaCheck ** | ||
** Copyright (c) 2007-2018 Rickard Nilsson. All rights reserved. ** | ||
** http://www.scalacheck.org ** | ||
** ** | ||
** This software is released under the terms of the Revised BSD License. ** | ||
** There is NO WARRANTY. See the file LICENSE for the full text. ** | ||
\*------------------------------------------------------------------------ */ | ||
|
||
package org.scalacheck | ||
|
||
import scala.collection.generic.Sorted | ||
import scala.collection.immutable.Stream | ||
import scala.collection.TraversableOnce | ||
|
||
private[scalacheck] object ScalaVersionSpecific { | ||
def toLazyList[T](i: TraversableOnce[T]) = i.toStream | ||
|
||
type LazyList[+A] = Stream[A] | ||
val LazyList = Stream | ||
|
||
implicit class StreamExt[+A](val s: Stream[A]) extends AnyVal { | ||
def lazyAppendedAll[B >: A](rest: => TraversableOnce[B]): Stream[B] = s.append(rest) | ||
} | ||
|
||
implicit class SortedExt[K, T <: Sorted[K, T]](val s: Sorted[K, T]) extends AnyVal { | ||
def rangeFrom(from: K): T = s.from(from) | ||
def rangeTo(to: K): T = s.to(to) | ||
def rangeUntil(until: K): T = s.until(until) | ||
} | ||
} | ||
|
||
private[scalacheck] trait GenVersionSpecific | ||
private[scalacheck] trait CogenVersionSpecific | ||
|
||
// Used in tests | ||
private[scalacheck] trait GenSpecificationVersionSpecific { | ||
def infiniteLazyList[T](g: => Gen[T]): Gen[Stream[T]] = Gen.infiniteStream(g) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exclude doesn't make sense like this anymore since the change from scala 2.13.0-M3 to 2.13.0-M4, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand.. This
exclude
skips building with Scala.js 1.0.0-M3 on Scala 2.13.0-M4, because there's no such Scala.js release yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A got it 👍