-
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
Conversation
This doesn't cross-compile with 2.11/2.12 and 2.13 though. If you want to keep cross-compiling a single branch, we can use version-dependent source directories. We can minimize the amount of code in those directories. |
d999db4
to
d7e7661
Compare
Yay, this is green now! @ashawley raises concerns about binary compatibility over at scala/scala-xml#222. Have to check in detail and see if we can keep doing 1.14.x, or need to move to 1.15. |
Co-authored-by: julienrf
This is a no-op for 2.13, as Traversable is a (deprecated) alias for Iterable. For 2.10-2.12, this ensures that the signatures don't change due to cross-building with 2.13.
I went through all the changes again with focus on binary and source compatibility. It looks to me like we can continue to release 0.14.x builds for 2.10-2.12 after merging this PR, they should be backwards compatible. I think this PR is ready now. Review by @rickynils :-) |
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 qualified to review most of the changes, but had a quick look and a couple of things popped out)
@@ -46,3 +49,5 @@ matrix: | |||
exclude: | |||
- scala: 2.10.7 | |||
env: PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true SCALAJS_VERSION=1.0.0-M3 | |||
- scala: 2.13.0-M4 | |||
env: PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true SCALAJS_VERSION=1.0.0-M3 |
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 👍
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment #410 (comment)
@@ -765,8 +766,8 @@ object Prop { | |||
/* | |||
* Returns the first failed result in Left or success in Right. | |||
*/ | |||
def getFirstFailure(xs: Stream[T]): Either[(T,Result),(T,Result)] = { | |||
assert(!xs.isEmpty, "Stream cannot be empty") | |||
def getFirstFailure(xs: LazyList[T]): Either[(T,Result),(T,Result)] = { |
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.
Is this binary compatible?
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.
Yes, because LazyList
is an alias for Stream
when building on 2.10-2.12 https://github.com/rickynils/scalacheck/blob/543b4056bffdb684faec49e8afb09aee4c24eb2f/src/main/scala-2.13-/org/scalacheck/ScalaVersionSpecific.scala#L19-L20
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.
👍
|
||
sealed abstract class Shrink[T] extends Serializable { | ||
def shrink(x: T): Stream[T] | ||
def shrink(x: T): LazyList[T] |
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.
So the signature for Shrink
changes here, so existing 1.14.0 tests (or libraries) that defined shrinkers would no longer compile.
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.
The signature is actually the same on 2.10-2.12, because LazyList
is an alias for Stream
there: https://github.com/rickynils/scalacheck/blob/543b4056bffdb684faec49e8afb09aee4c24eb2f/src/main/scala-2.13-/org/scalacheck/ScalaVersionSpecific.scala#L19-L20
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.
Here's an example shrinker:
object CustomShrink {
implicit val dumbIntShrinker: Shrink[Int] = Shrink {
case _ => Stream.empty
}
}
Publishing this branch as 1.14.0-543b405, the example compiles on 2.10, 2.11, and 2.12, but for 2.13.0-M4:
[error] src/main/scala/CustomShrink.scala:5:22: polymorphic expression cannot be instantiated to expected type;
[error] found : [A]scala.collection.immutable.Stream[A]
[error] required: LazyList[Int]
[error] case _ => Stream.empty
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.
Thank you for pointing this out.
Do poeple actually write shrinkers "ahead of time", at the same time when writing Arbitrary
instances, and put them into the code base?
We could make the LazyList
aliases public on 2.10-2.12, then poeople could use these. But I think this gets even more confusing. Already having the LazyList
alias in the signatures on 2.10-2.12 is a bit problematic.
We could keep using Stream
, but that would lead to deprecation warnings on 2.13.
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.
Yeah, writing one's own Shrink
is documented.
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.
Aren't warnings being emitted for Traversable
?
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.
There are a number of uses of Traversable
in the API, but I think they should not lead to deprecation warnings for the users. In 2.13, Traversable
is a (deprecated) alias to Iterable
.
So let's say scalacheck defines a method
scala> def foo: Traversable[Int] = List(1,2,3)
^
warning: type Traversable in package scala is deprecated (since 2.13.0): Use Iterable instead of Traversable
foo: Traversable[Int]
When compiling scalacheck on 2.13, this will give a deprecation warning. But for users it won't:
scala> foo
res0: Traversable[Int] = List(1, 2, 3)
scala> foo.map(_ + 1)
res1: Iterable[Int] = List(2, 3, 4)
scala> foo: Iterable[Int]
res2: Iterable[Int] = List(1, 2, 3)
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.
Ah, ok. I see the distinction. Thanks for explaining.
For now, preserve Stream
in Shrink
, and then migrate to LazyList
in 1.15.0?
Pushed a change by @ashawley to go back to using |
With `n == 0` the test effectively calls `Gen.frequency()`, which throws `IllegalArgumentException: no items with positive weights`.
I'd say this is good to publish for 2.13.0-M4. Since there are long-term implications with 2.13 that require further consideration going forward (like, "What should go in 1.15.0?"), maybe hold off on the merge? |
@ashawley I'v rebased and merged this to the 1.14.0_sonatype branch and published the build. I'm not sure I see why we should hold off the merge to master, though? |
This PR currently represents the conservative set of changes for making a 1.14.0 release for 2.13. Publishing was important for getting a ScalaCheck release out for the 2.13.0-M4 milestone . That's all that's been really reviewed, though. What wasn't probably reviewed, was the first half of these commits of this PR containing the original re-implementation of ScalaCheck's use of collections for 2.13. Those modifications have compatibility breaking changes, but they would seem like the better base with which to move forward on. |
In the current form this PR doesn't have breaking changes, those parts of the earlier commits are reverted in later commits. I can squash things if that's desired. Changes such as moving to use |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
does it mean 2.13 enables -Xfatal-warnings
by default?
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.
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 comment
The 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
Are there any blockers for this PR? Scala 2.13.0-M5 is out now. |
M5 is out, but I'm not sure it's minted, yet. For the record, this was merged to the 1.14.0_sonatype branch in #410, but just not master, yet. Since development isn't active, this is effectively a longer-running branch/PR for 2.13. |
It would be great to move 2.13 cross-building forward. As mentioned in a recent announcement, one goal of the postponed RC1 is to make sure we have time to get the OSS ecosystem up and running. Scalacheck is obviously very important as it's one of the roots. I'll update this PR to M5. |
Seth got ScalaCheck most of the way there for 2.13.0-M5, see #427. |
I have merged |
No description provided.