From 99fdcc1d126209bac32e1448ff1a0c6963b9b29e Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Fri, 21 Nov 2025 11:59:17 +0100 Subject: [PATCH 1/5] remove the usage of `@elidable` from the library --- library/src/scala/Predef.scala | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/library/src/scala/Predef.scala b/library/src/scala/Predef.scala index 5cb4742bf168..84d02abc695d 100644 --- a/library/src/scala/Predef.scala +++ b/library/src/scala/Predef.scala @@ -16,7 +16,7 @@ import scala.language.`2.13` import scala.language.implicitConversions import scala.collection.{mutable, immutable, ArrayOps, StringOps}, immutable.WrappedString -import scala.annotation.{elidable, experimental, implicitNotFound, publicInBinary, targetName }, elidable.ASSERTION +import scala.annotation.{experimental, implicitNotFound, publicInBinary, targetName } import scala.annotation.meta.{ companionClass, companionMethod } import scala.annotation.internal.{ RuntimeChecked } import scala.compiletime.summonFrom @@ -36,9 +36,7 @@ import scala.runtime.ScalaRunTime.mapNull * * === Assertions === * A set of `assert` functions are provided for use as a way to document - * and dynamically check invariants in code. Invocations of `assert` can be elided - * at compile time by providing the command line option `-Xdisable-assertions`, - * which raises `-Xelide-below` above `elidable.ASSERTION`, to the `scalac` command. + * and dynamically check invariants in code. * * Variants of `assert` intended for use with static analysis tools are also * provided: `assume`, `require` and `ensuring`. `require` and `ensuring` are @@ -298,29 +296,23 @@ object Predef extends LowPriorityImplicits { */ /** Tests an expression, throwing an `AssertionError` if false. - * Calls to this method will not be generated if `-Xelide-below` - * is greater than `ASSERTION`. * - * @see [[scala.annotation.elidable elidable]] * @param assertion the expression to test * @group assertions */ - @elidable(ASSERTION) @publicInBinary + @publicInBinary @targetName("assert") private[scala] def scala2Assert(assertion: Boolean): Unit = { if (!assertion) throw new java.lang.AssertionError("assertion failed") } /** Tests an expression, throwing an `AssertionError` if false. - * Calls to this method will not be generated if `-Xelide-below` - * is greater than `ASSERTION`. * - * @see [[scala.annotation.elidable elidable]] * @param assertion the expression to test * @param message a String to include in the failure message * @group assertions */ - @elidable(ASSERTION) @inline @publicInBinary + @inline @publicInBinary @targetName("assert") private[scala] final def scala2Assert(assertion: Boolean, message: => Any): Unit = { if (!assertion) throw new java.lang.AssertionError("assertion failed: "+ message) @@ -339,14 +331,11 @@ object Predef extends LowPriorityImplicits { /** Tests an expression, throwing an `AssertionError` if false. * This method differs from assert only in the intent expressed: * assert contains a predicate which needs to be proven, while - * assume contains an axiom for a static checker. Calls to this method - * will not be generated if `-Xelide-below` is greater than `ASSERTION`. + * assume contains an axiom for a static checker. * - * @see [[scala.annotation.elidable elidable]] * @param assumption the expression to test * @group assertions */ - @elidable(ASSERTION) def assume(assumption: Boolean): Unit = { if (!assumption) throw new java.lang.AssertionError("assumption failed") @@ -355,16 +344,13 @@ object Predef extends LowPriorityImplicits { /** Tests an expression, throwing an `AssertionError` if false. * This method differs from assert only in the intent expressed: * assert contains a predicate which needs to be proven, while - * assume contains an axiom for a static checker. Calls to this method - * will not be generated if `-Xelide-below` is greater than `ASSERTION`. + * assume contains an axiom for a static checker. * - * @see [[scala.annotation.elidable elidable]] * @param assumption the expression to test * @param message a String to include in the failure message * @group assertions */ - @elidable(ASSERTION) @inline - final def assume(assumption: Boolean, message: => Any): Unit = { + @inline final def assume(assumption: Boolean, message: => Any): Unit = { if (!assumption) throw new java.lang.AssertionError("assumption failed: "+ message) } From 5029b89aba58e3c5b0787321d67fff246883a8e0 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Fri, 21 Nov 2025 12:14:42 +0100 Subject: [PATCH 2/5] remove the warnings in `scala.Predef` --- library/src/scala/Predef.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/src/scala/Predef.scala b/library/src/scala/Predef.scala index 84d02abc695d..e666b21c05e9 100644 --- a/library/src/scala/Predef.scala +++ b/library/src/scala/Predef.scala @@ -16,7 +16,7 @@ import scala.language.`2.13` import scala.language.implicitConversions import scala.collection.{mutable, immutable, ArrayOps, StringOps}, immutable.WrappedString -import scala.annotation.{experimental, implicitNotFound, publicInBinary, targetName } +import scala.annotation.{experimental, implicitNotFound, publicInBinary, targetName, nowarn } import scala.annotation.meta.{ companionClass, companionMethod } import scala.annotation.internal.{ RuntimeChecked } import scala.compiletime.summonFrom @@ -490,7 +490,9 @@ object Predef extends LowPriorityImplicits { // these two are morally deprecated but the @deprecated annotation has been moved to the extension method themselves, // in order to provide a more specific deprecation method. + @nowarn("""cat=deprecation&origin=scala\.runtime\.Tuple2Zipped""") implicit def tuple2ToZippedOps[T1, T2](x: (T1, T2)): runtime.Tuple2Zipped.Ops[T1, T2] = new runtime.Tuple2Zipped.Ops(x) + @nowarn("""cat=deprecation&origin=scala\.runtime\.Tuple3Zipped""") implicit def tuple3ToZippedOps[T1, T2, T3](x: (T1, T2, T3)): runtime.Tuple3Zipped.Ops[T1, T2, T3] = new runtime.Tuple3Zipped.Ops(x) // Not specialized anymore since 2.13 but we still need separate methods From af3df7770a222135919fed9817f55186cb36ebd4 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Fri, 21 Nov 2025 12:32:57 +0100 Subject: [PATCH 3/5] cast away nullability in `CollisionProofHashMap.next` --- .../src/scala/collection/mutable/CollisionProofHashMap.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/scala/collection/mutable/CollisionProofHashMap.scala b/library/src/scala/collection/mutable/CollisionProofHashMap.scala index e2fb03cf14a5..34002a4b393b 100644 --- a/library/src/scala/collection/mutable/CollisionProofHashMap.scala +++ b/library/src/scala/collection/mutable/CollisionProofHashMap.scala @@ -243,7 +243,7 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double def next(): R = if(!hasNext) Iterator.empty.next() - else node match { + else node.nn match { case n: RBNode @uc => val r = extract(n) node = CollisionProofHashMap.successor(n ) From 77cdc4342249d139dfae8286063e8ceebf77f92e Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Fri, 21 Nov 2025 12:34:08 +0100 Subject: [PATCH 4/5] remove imports to deprecated elements --- .../collection/convert/ImplicitConversions.scala | 4 +++- library/src/scala/collection/immutable/Stream.scala | 12 +++++------- library/src/scala/runtime/ScalaNumberProxy.scala | 7 +++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/library/src/scala/collection/convert/ImplicitConversions.scala b/library/src/scala/collection/convert/ImplicitConversions.scala index b2ebd48f16e9..b5e0d00c08dd 100644 --- a/library/src/scala/collection/convert/ImplicitConversions.scala +++ b/library/src/scala/collection/convert/ImplicitConversions.scala @@ -20,12 +20,13 @@ import language.experimental.captureChecking import java.util.{concurrent => juc} import java.{lang => jl, util => ju} -import scala.collection.JavaConverters._ import scala.language.implicitConversions /** Defines implicit converter methods from Java to Scala collections. */ @deprecated("Use `scala.jdk.CollectionConverters` instead", "2.13.0") trait ToScalaImplicits { + import scala.collection.JavaConverters.* + /** Implicitly converts a Java `Iterator` to a Scala `Iterator`. * @see [[JavaConverters.asScalaIterator]] */ @@ -80,6 +81,7 @@ trait ToScalaImplicits { /** Defines implicit conversions from Scala to Java collections. */ @deprecated("Use `scala.jdk.CollectionConverters` instead", "2.13.0") trait ToJavaImplicits { + import scala.collection.JavaConverters.* /** Implicitly converts a Scala `Iterator` to a Java `Iterator`. * @see [[JavaConverters.asJavaIterator]] */ diff --git a/library/src/scala/collection/immutable/Stream.scala b/library/src/scala/collection/immutable/Stream.scala index 05e1bcaf087a..b795c0429c33 100644 --- a/library/src/scala/collection/immutable/Stream.scala +++ b/library/src/scala/collection/immutable/Stream.scala @@ -25,8 +25,6 @@ import scala.collection.mutable.{ArrayBuffer, StringBuilder} import scala.language.implicitConversions import scala.runtime.ScalaRunTime.nullForGC -import Stream.cons - @deprecated("Use LazyListIterable (which is fully lazy) instead of Stream (which has a lazy tail only)", "2.13.0") @SerialVersionUID(3L) sealed abstract class Stream[+A] extends AbstractSeq[A] @@ -123,11 +121,11 @@ sealed abstract class Stream[+A] extends AbstractSeq[A] * @return The stream containing elements of this stream and the iterable object. */ def lazyAppendedAll[B >: A](suffix: => collection.IterableOnce[B]): Stream[B] = - if (isEmpty) iterableFactory.from(suffix) else cons[B](head, tail.lazyAppendedAll(suffix)) + if (isEmpty) iterableFactory.from(suffix) else Stream.cons[B](head, tail.lazyAppendedAll(suffix)) override def scanLeft[B](z: B)(op: (B, A) => B): Stream[B] = if (isEmpty) z +: iterableFactory.empty - else cons(z, tail.scanLeft(op(z, head))(op)) + else Stream.cons(z, tail.scanLeft(op(z, head))(op)) /** Stream specialization of reduceLeft which allows GC to collect * along the way. @@ -169,11 +167,11 @@ sealed abstract class Stream[+A] extends AbstractSeq[A] override final def withFilter(p: A => Boolean): collection.WithFilter[A, Stream] = Stream.withFilter(coll, p) - override final def prepended[B >: A](elem: B): Stream[B] = cons(elem, coll) + override final def prepended[B >: A](elem: B): Stream[B] = Stream.cons(elem, coll) override final def map[B](f: A => B): Stream[B] = if (isEmpty) iterableFactory.empty - else cons(f(head), tail.map(f)) + else Stream.cons(f(head), tail.map(f)) @tailrec override final def collect[B](pf: PartialFunction[A, B]): Stream[B] = if(isEmpty) Stream.empty @@ -218,7 +216,7 @@ sealed abstract class Stream[+A] extends AbstractSeq[A] case that: collection.Iterable[B] => that case _ => LazyList.from(that) } - cons[(A, B)]((this.head, thatIterable.head), this.tail.zip(thatIterable.tail)) + Stream.cons[(A, B)]((this.head, thatIterable.head), this.tail.zip(thatIterable.tail)) } override final def zipWithIndex: Stream[(A, Int)] = this.zip(LazyList.from(0)) diff --git a/library/src/scala/runtime/ScalaNumberProxy.scala b/library/src/scala/runtime/ScalaNumberProxy.scala index cf70558469de..3b656d83ff84 100644 --- a/library/src/scala/runtime/ScalaNumberProxy.scala +++ b/library/src/scala/runtime/ScalaNumberProxy.scala @@ -17,14 +17,13 @@ import scala.language.`2.13` import scala.collection.immutable import scala.math.ScalaNumericAnyConversions import immutable.NumericRange -import Proxy.Typed import scala.annotation.nowarn /** Base classes for the Rich* wrappers of the primitive types. * As with all classes in scala.runtime.*, this is not a supported API. */ @nowarn("cat=deprecation") -trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Typed[T] with OrderedProxy[T] { +trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Proxy.Typed[T] with OrderedProxy[T] { protected implicit def num: Numeric[T] def doubleValue = num.toDouble(self) @@ -70,14 +69,14 @@ trait FractionalProxy[T] extends Any with ScalaNumberProxy[T] { } @nowarn("cat=deprecation") -trait OrderedProxy[T] extends Any with Ordered[T] with Typed[T] { +trait OrderedProxy[T] extends Any with Ordered[T] with Proxy.Typed[T] { protected def ord: Ordering[T] def compare(y: T) = ord.compare(self, y) } @nowarn("cat=deprecation") -trait RangedProxy[T] extends Any with Typed[T] { +trait RangedProxy[T] extends Any with Proxy.Typed[T] { type ResultWithoutStep def until(end: T): ResultWithoutStep From 55db92aece753b66d0b16dde0dc42789cff927d5 Mon Sep 17 00:00:00 2001 From: Hamza Remmal Date: Fri, 21 Nov 2025 12:34:44 +0100 Subject: [PATCH 5/5] do not warn for explicitely overriden `stringPrefix` --- library/src/scala/collection/mutable/ListMap.scala | 3 ++- library/src/scala/collection/mutable/OpenHashMap.scala | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/library/src/scala/collection/mutable/ListMap.scala b/library/src/scala/collection/mutable/ListMap.scala index b3fd650754a5..e2ea36798087 100644 --- a/library/src/scala/collection/mutable/ListMap.scala +++ b/library/src/scala/collection/mutable/ListMap.scala @@ -15,7 +15,7 @@ package mutable import scala.language.`2.13` import language.experimental.captureChecking -import scala.annotation.tailrec +import scala.annotation.{tailrec, nowarn} import scala.collection.generic.DefaultSerializable import scala.collection.immutable.List @@ -68,6 +68,7 @@ class ListMap[K, V] final override def size: Int = siz override def knownSize: Int = size override def isEmpty: Boolean = size == 0 + @nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""") override protected def stringPrefix = "ListMap" } diff --git a/library/src/scala/collection/mutable/OpenHashMap.scala b/library/src/scala/collection/mutable/OpenHashMap.scala index 1f3a23da4447..e10ef8904dff 100644 --- a/library/src/scala/collection/mutable/OpenHashMap.scala +++ b/library/src/scala/collection/mutable/OpenHashMap.scala @@ -15,6 +15,8 @@ package mutable import scala.language.`2.13` import language.experimental.captureChecking + +import scala.annotation.nowarn import java.lang.Integer.numberOfLeadingZeros import java.util.ConcurrentModificationException import scala.collection.generic.DefaultSerializable @@ -304,5 +306,6 @@ class OpenHashMap[Key, Value](initialSize : Int) this } + @nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""") override protected def stringPrefix = "OpenHashMap" }