From 3fe7949520429f2da0c6a74d0d650fb9925da22d Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Mon, 12 Aug 2019 18:45:57 +0200 Subject: [PATCH] Add IterableOnce operations to IterableOnceOps Fixes scala/bug#11675 This change is backward compatible, because nothing is removed. It should also be forward compatible, because `IterableOnceOps[A]` had `IterableOnce[A]` as a self-type on 2.13.0, meaning that code relying on the newly introduced methods also worked on 2.13.0 because any `IterableOnceOps[A]` instance was also effectively an `IterableOnce[A]`. --- build.sbt | 4 ++-- src/library/scala/collection/IterableOnce.scala | 3 ++- test/files/neg/abstract-report.check | 2 +- test/files/neg/abstract-report2.check | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index f91291695c73..4d46a172f1a9 100644 --- a/build.sbt +++ b/build.sbt @@ -93,8 +93,8 @@ val mimaFilterSettings = Seq( ProblemFilters.exclude[DirectMissingMethodProblem]("scala.reflect.runtime.JavaMirrors#JavaMirror.typeTag"), ProblemFilters.exclude[MissingClassProblem]("scala.reflect.runtime.JavaMirrors$JavaMirror$typeTagCache$"), ProblemFilters.exclude[DirectMissingMethodProblem]("scala.reflect.api.TypeTags.TypeTagImpl"), - ProblemFilters.exclude[DirectMissingMethodProblem]("scala.reflect.api.Universe.TypeTagImpl"), - ), + ProblemFilters.exclude[DirectMissingMethodProblem]("scala.reflect.api.Universe.TypeTagImpl") + ) ) // Save MiMa logs diff --git a/src/library/scala/collection/IterableOnce.scala b/src/library/scala/collection/IterableOnce.scala index 6bb57c028b4d..c7773f0386a3 100644 --- a/src/library/scala/collection/IterableOnce.scala +++ b/src/library/scala/collection/IterableOnce.scala @@ -296,7 +296,8 @@ object IterableOnce { * @define coll collection * */ -trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] => +trait IterableOnceOps[+A, +CC[_], +C] extends Any with IterableOnce[A] { + /////////////////////////////////////////////////////////////// Abstract methods that must be implemented /** Produces a $coll containing cumulative results of applying the diff --git a/test/files/neg/abstract-report.check b/test/files/neg/abstract-report.check index 21a70a329c06..2d36b72aec48 100644 --- a/test/files/neg/abstract-report.check +++ b/test/files/neg/abstract-report.check @@ -1,6 +1,6 @@ abstract-report.scala:1: error: class Unimplemented needs to be abstract. Missing implementations for 6 members. Stub implementations follow: - // Members declared in scala.collection.IterableOnce + // Members declared in scala.collection.IterableOnceOps def iterator: Iterator[String] = ??? // Members declared in scala.collection.IterableOps diff --git a/test/files/neg/abstract-report2.check b/test/files/neg/abstract-report2.check index b64d7d4eede7..87f7f1419f97 100644 --- a/test/files/neg/abstract-report2.check +++ b/test/files/neg/abstract-report2.check @@ -54,7 +54,7 @@ class Baz[T] extends Collection[T] ^ abstract-report2.scala:15: error: class Dingus needs to be abstract. Missing implementations for 7 members. Stub implementations follow: - // Members declared in scala.collection.IterableOnce + // Members declared in scala.collection.IterableOnceOps def iterator: Iterator[(Set[Int], String)] = ??? // Members declared in scala.collection.IterableOps