Skip to content

Remove unnecessary type parameter on IterableOnce#stepper #8083

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

Merged
merged 2 commits into from
May 28, 2019

Conversation

szeiger
Copy link
Contributor

@szeiger szeiger commented May 24, 2019

This also requires a contravariant StepperShape. Without this change it is impossible to delegate easily (without casting) from such a stepper implementation to one without the extra type parameter (see StepperTest). It also makes the signatures less ugly.

@szeiger szeiger added this to the 2.13.0-RC3 milestone May 24, 2019
@szeiger szeiger requested a review from lrytz May 24, 2019 17:39
@szeiger
Copy link
Contributor Author

szeiger commented May 24, 2019

Huh, that's unexpected. The method was final before and it's final after. I expected these changes to be binary compatible.

[error]  * method stepper(scala.collection.StepperShape)scala.collection.Stepper in class scala.jdk.Accumulator is declared final in current version
[error]    filter with: ProblemFilters.exclude[FinalMethodProblem]("scala.jdk.Accumulator.stepper")

@diesalbla diesalbla added the library:collections PRs involving changes to the standard collection library label May 26, 2019
@retronym
Copy link
Member

retronym commented May 27, 2019

The MiMa change is due to specialization:

$ jardiff -c $(scala-classpath $(scala-ref-version 90491f5~1)) $(scala-classpath $(scala-ref-version 90491f5))
...
diff --git a/scala/jdk/Accumulator.class.asm b/scala/jdk/Accumulator.class.asm
index ca5cb79..935cf3a 100644
--- a/scala/jdk/Accumulator.class.asm
+++ b/scala/jdk/Accumulator.class.asm
@@ -401,27 +401,9 @@
     // parameter final  p

   // access flags 0x401
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
+  // signature <S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TA;TS;>;)TS;
+  // declaration: S <S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<A, S>)
   public abstract efficientStepper(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
-    // parameter final  shape
-
-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public efficientStepper$mcD$sp(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
-    // parameter final  shape
-
-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public efficientStepper$mcI$sp(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
-    // parameter final  shape
-
-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public efficientStepper$mcJ$sp(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
     // parameter final  shape

   // access flags 0x1
@@ -1204,28 +1186,10 @@
   // declaration: int <B>()
   public startsWith$default$2()I

-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public stepper(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
-    // parameter final  shape
-
-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public stepper$mcD$sp(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
-    // parameter final  shape
-
-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public stepper$mcI$sp(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
-    // parameter final  shape
-
-  // access flags 0x1
-  // signature <B:Ljava/lang/Object;S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TB;TS;>;)TS;
-  // declaration: S <B, S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<B, S>)
-  public stepper$mcJ$sp(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
+  // access flags 0x11
+  // signature <S::Lscala/collection/Stepper<*>;>(Lscala/collection/StepperShape<TA;TS;>;)TS;
+  // declaration: S <S extends scala.collection.Stepper<?>>(scala.collection.StepperShape<A, S>)
+  public final stepper(Lscala/collection/StepperShape;)Lscala/collection/Stepper;
     // parameter final  shape

   // access flags 0x1

@@ -84,8 +84,8 @@ trait StreamExtensions {

implicit class MapHasParKeyValueStream[K, V, CC[X, Y] <: collection.MapOps[X, Y, CC, _]](cc: CC[K, V]) {
private type MapOpsWithEfficientKeyStepper[K, V] = collection.MapOps[K, V, CC, _] { def keyStepper[S <: Stepper[_]](implicit shape : StepperShape[K, S]) : S with EfficientSplit }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the shadowing of K and V here intended?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not intended, but it's not a bug :-)

Copy link
Member

@lrytz lrytz May 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adriaanm adriaanm mentioned this pull request May 28, 2019
54 tasks
@adriaanm
Copy link
Contributor

@szeiger could you appease mima, perhaps also rebase to avoid potential conflict?

@adriaanm
Copy link
Contributor

did the rebase

@adriaanm
Copy link
Contributor

Looks like this also has a junit test failure?

This also requires a contravariant `StepperShape`.

Without this change it is impossible to delegate easily
(without casting) from such a `stepper` implementation to
one without the extra type parameter (see `StepperTest`).

It also makes the signatures less ugly.
@adriaanm adriaanm force-pushed the wip/contravariant-steppershape branch from 4b00073 to f3b3f9a Compare May 28, 2019 19:04
@adriaanm adriaanm merged commit a574e3a into scala:2.13.x May 28, 2019
@sjrd
Copy link
Member

sjrd commented May 28, 2019

Oh no! No, no, no, no, no. This PR broke Scala.js 0.6.28, which I had specifically released to support 2.13. It triggers a compilation error in the file Range.scala, for which we have an override (so we override the source of the upstream Range.scala with some changes):

[error] /localhome/doeraene/projects/scalajs-0.6.x/scalalib/overrides-2.13/scala/collection/immutable/Range.scala:73: error: method stepper overrides nothing.
[error] Note: the super classes of class Range contain the following, non final members named stepper:
[error] override def stepper[S <: scala.collection.Stepper[_]](implicit shape: scala.collection.StepperShape[Int,S]): S with collection.Stepper.EfficientSplit
[error]   override final def stepper[B >: Int, S <: Stepper[_]](implicit shape: StepperShape[B, S]): S with EfficientSplit = {
[error]                      ^
[error] /localhome/doeraene/projects/scalajs-0.6.x/scalalib/overrides-2.13/scala/collection/immutable/NumericRange.scala:57: error: method stepper overrides nothing.
[error] Note: the super classes of class NumericRange contain the following, non final members named stepper:
[error] override def stepper[S <: scala.collection.Stepper[_]](implicit shape: scala.collection.StepperShape[T,S]): S with collection.Stepper.EfficientSplit
[error]   override def stepper[B >: T, S <: Stepper[_]](implicit shape: StepperShape[B, S]): S with EfficientSplit = {
[error]                ^
[info] two errors found

Is there anything that can be done on Scala's side to fix this? Because otherwise I'll despair at having to re-do yet another release in emergency mode (and I really don't have time for this now, with Scala Days approaching).

@adriaanm
Copy link
Contributor

adriaanm commented May 28, 2019

I can't think of anything except for reverting this PR or delaying the RC. (EDIT: more inclined towards the latter, as this PR was the whole reason for doing RC3)

@sjrd
Copy link
Member

sjrd commented May 28, 2019

Well, I think what I'll do is cheat. I will live-patch Range.scala (and NumericRange.scala) on top of 0.6.28 to be able to publish it for 2.13.0-RC3 (and final I guess). That means that the sources for that release will not correspond to any preserved commit sha, but maybe that's OK in this case because it's just adapting an override file for an upstream change...

@adriaanm
Copy link
Contributor

Ok, let me know if there's something we can do to make this annoyance somewhat less annoying. We're all really eager to get that final release out the door!

@sjrd
Copy link
Member

sjrd commented May 28, 2019

Nah, I don't think there's anything that can be done. Just ship it.

@SethTisue SethTisue added the release-notes worth highlighting in next release notes label May 30, 2019
sjrd added a commit to sjrd/scala-js that referenced this pull request Jun 4, 2019
sjrd added a commit to sjrd/scala-js that referenced this pull request Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library:collections PRs involving changes to the standard collection library release-notes worth highlighting in next release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants