Skip to content

Commit 5e99614

Browse files
authored
Another round removing warnings (#24500)
So far, we still have pattern matching warnings, init warnings, a bug in the deprecatedOverride logic that triggers warnings because of generated code and some CC warnings too.
2 parents 7dc9327 + 55db92a commit 5e99614

File tree

7 files changed

+26
-35
lines changed

7 files changed

+26
-35
lines changed

library/src/scala/Predef.scala

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import scala.language.`2.13`
1616
import scala.language.implicitConversions
1717

1818
import scala.collection.{mutable, immutable, ArrayOps, StringOps}, immutable.WrappedString
19-
import scala.annotation.{elidable, experimental, implicitNotFound, publicInBinary, targetName }, elidable.ASSERTION
19+
import scala.annotation.{experimental, implicitNotFound, publicInBinary, targetName, nowarn }
2020
import scala.annotation.meta.{ companionClass, companionMethod }
2121
import scala.annotation.internal.{ RuntimeChecked }
2222
import scala.compiletime.summonFrom
@@ -36,9 +36,7 @@ import scala.runtime.ScalaRunTime.mapNull
3636
*
3737
* === Assertions ===
3838
* A set of `assert` functions are provided for use as a way to document
39-
* and dynamically check invariants in code. Invocations of `assert` can be elided
40-
* at compile time by providing the command line option `-Xdisable-assertions`,
41-
* which raises `-Xelide-below` above `elidable.ASSERTION`, to the `scalac` command.
39+
* and dynamically check invariants in code.
4240
*
4341
* Variants of `assert` intended for use with static analysis tools are also
4442
* provided: `assume`, `require` and `ensuring`. `require` and `ensuring` are
@@ -298,29 +296,23 @@ object Predef extends LowPriorityImplicits {
298296
*/
299297

300298
/** Tests an expression, throwing an `AssertionError` if false.
301-
* Calls to this method will not be generated if `-Xelide-below`
302-
* is greater than `ASSERTION`.
303299
*
304-
* @see [[scala.annotation.elidable elidable]]
305300
* @param assertion the expression to test
306301
* @group assertions
307302
*/
308-
@elidable(ASSERTION) @publicInBinary
303+
@publicInBinary
309304
@targetName("assert") private[scala] def scala2Assert(assertion: Boolean): Unit = {
310305
if (!assertion)
311306
throw new java.lang.AssertionError("assertion failed")
312307
}
313308

314309
/** Tests an expression, throwing an `AssertionError` if false.
315-
* Calls to this method will not be generated if `-Xelide-below`
316-
* is greater than `ASSERTION`.
317310
*
318-
* @see [[scala.annotation.elidable elidable]]
319311
* @param assertion the expression to test
320312
* @param message a String to include in the failure message
321313
* @group assertions
322314
*/
323-
@elidable(ASSERTION) @inline @publicInBinary
315+
@inline @publicInBinary
324316
@targetName("assert") private[scala] final def scala2Assert(assertion: Boolean, message: => Any): Unit = {
325317
if (!assertion)
326318
throw new java.lang.AssertionError("assertion failed: "+ message)
@@ -339,14 +331,11 @@ object Predef extends LowPriorityImplicits {
339331
/** Tests an expression, throwing an `AssertionError` if false.
340332
* This method differs from assert only in the intent expressed:
341333
* assert contains a predicate which needs to be proven, while
342-
* assume contains an axiom for a static checker. Calls to this method
343-
* will not be generated if `-Xelide-below` is greater than `ASSERTION`.
334+
* assume contains an axiom for a static checker.
344335
*
345-
* @see [[scala.annotation.elidable elidable]]
346336
* @param assumption the expression to test
347337
* @group assertions
348338
*/
349-
@elidable(ASSERTION)
350339
def assume(assumption: Boolean): Unit = {
351340
if (!assumption)
352341
throw new java.lang.AssertionError("assumption failed")
@@ -355,16 +344,13 @@ object Predef extends LowPriorityImplicits {
355344
/** Tests an expression, throwing an `AssertionError` if false.
356345
* This method differs from assert only in the intent expressed:
357346
* assert contains a predicate which needs to be proven, while
358-
* assume contains an axiom for a static checker. Calls to this method
359-
* will not be generated if `-Xelide-below` is greater than `ASSERTION`.
347+
* assume contains an axiom for a static checker.
360348
*
361-
* @see [[scala.annotation.elidable elidable]]
362349
* @param assumption the expression to test
363350
* @param message a String to include in the failure message
364351
* @group assertions
365352
*/
366-
@elidable(ASSERTION) @inline
367-
final def assume(assumption: Boolean, message: => Any): Unit = {
353+
@inline final def assume(assumption: Boolean, message: => Any): Unit = {
368354
if (!assumption)
369355
throw new java.lang.AssertionError("assumption failed: "+ message)
370356
}
@@ -504,7 +490,9 @@ object Predef extends LowPriorityImplicits {
504490

505491
// these two are morally deprecated but the @deprecated annotation has been moved to the extension method themselves,
506492
// in order to provide a more specific deprecation method.
493+
@nowarn("""cat=deprecation&origin=scala\.runtime\.Tuple2Zipped""")
507494
implicit def tuple2ToZippedOps[T1, T2](x: (T1, T2)): runtime.Tuple2Zipped.Ops[T1, T2] = new runtime.Tuple2Zipped.Ops(x)
495+
@nowarn("""cat=deprecation&origin=scala\.runtime\.Tuple3Zipped""")
508496
implicit def tuple3ToZippedOps[T1, T2, T3](x: (T1, T2, T3)): runtime.Tuple3Zipped.Ops[T1, T2, T3] = new runtime.Tuple3Zipped.Ops(x)
509497

510498
// Not specialized anymore since 2.13 but we still need separate methods

library/src/scala/collection/convert/ImplicitConversions.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import language.experimental.captureChecking
2020
import java.util.{concurrent => juc}
2121
import java.{lang => jl, util => ju}
2222

23-
import scala.collection.JavaConverters._
2423
import scala.language.implicitConversions
2524

2625
/** Defines implicit converter methods from Java to Scala collections. */
2726
@deprecated("Use `scala.jdk.CollectionConverters` instead", "2.13.0")
2827
trait ToScalaImplicits {
28+
import scala.collection.JavaConverters.*
29+
2930
/** Implicitly converts a Java `Iterator` to a Scala `Iterator`.
3031
* @see [[JavaConverters.asScalaIterator]]
3132
*/
@@ -80,6 +81,7 @@ trait ToScalaImplicits {
8081
/** Defines implicit conversions from Scala to Java collections. */
8182
@deprecated("Use `scala.jdk.CollectionConverters` instead", "2.13.0")
8283
trait ToJavaImplicits {
84+
import scala.collection.JavaConverters.*
8385
/** Implicitly converts a Scala `Iterator` to a Java `Iterator`.
8486
* @see [[JavaConverters.asJavaIterator]]
8587
*/

library/src/scala/collection/immutable/Stream.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import scala.collection.mutable.{ArrayBuffer, StringBuilder}
2525
import scala.language.implicitConversions
2626
import scala.runtime.ScalaRunTime.nullForGC
2727

28-
import Stream.cons
29-
3028
@deprecated("Use LazyListIterable (which is fully lazy) instead of Stream (which has a lazy tail only)", "2.13.0")
3129
@SerialVersionUID(3L)
3230
sealed abstract class Stream[+A] extends AbstractSeq[A]
@@ -123,11 +121,11 @@ sealed abstract class Stream[+A] extends AbstractSeq[A]
123121
* @return The stream containing elements of this stream and the iterable object.
124122
*/
125123
def lazyAppendedAll[B >: A](suffix: => collection.IterableOnce[B]): Stream[B] =
126-
if (isEmpty) iterableFactory.from(suffix) else cons[B](head, tail.lazyAppendedAll(suffix))
124+
if (isEmpty) iterableFactory.from(suffix) else Stream.cons[B](head, tail.lazyAppendedAll(suffix))
127125

128126
override def scanLeft[B](z: B)(op: (B, A) => B): Stream[B] =
129127
if (isEmpty) z +: iterableFactory.empty
130-
else cons(z, tail.scanLeft(op(z, head))(op))
128+
else Stream.cons(z, tail.scanLeft(op(z, head))(op))
131129

132130
/** Stream specialization of reduceLeft which allows GC to collect
133131
* along the way.
@@ -169,11 +167,11 @@ sealed abstract class Stream[+A] extends AbstractSeq[A]
169167
override final def withFilter(p: A => Boolean): collection.WithFilter[A, Stream] =
170168
Stream.withFilter(coll, p)
171169

172-
override final def prepended[B >: A](elem: B): Stream[B] = cons(elem, coll)
170+
override final def prepended[B >: A](elem: B): Stream[B] = Stream.cons(elem, coll)
173171

174172
override final def map[B](f: A => B): Stream[B] =
175173
if (isEmpty) iterableFactory.empty
176-
else cons(f(head), tail.map(f))
174+
else Stream.cons(f(head), tail.map(f))
177175

178176
@tailrec override final def collect[B](pf: PartialFunction[A, B]): Stream[B] =
179177
if(isEmpty) Stream.empty
@@ -218,7 +216,7 @@ sealed abstract class Stream[+A] extends AbstractSeq[A]
218216
case that: collection.Iterable[B] => that
219217
case _ => LazyList.from(that)
220218
}
221-
cons[(A, B)]((this.head, thatIterable.head), this.tail.zip(thatIterable.tail))
219+
Stream.cons[(A, B)]((this.head, thatIterable.head), this.tail.zip(thatIterable.tail))
222220
}
223221

224222
override final def zipWithIndex: Stream[(A, Int)] = this.zip(LazyList.from(0))

library/src/scala/collection/mutable/CollisionProofHashMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double
243243

244244
def next(): R =
245245
if(!hasNext) Iterator.empty.next()
246-
else node match {
246+
else node.nn match {
247247
case n: RBNode @uc =>
248248
val r = extract(n)
249249
node = CollisionProofHashMap.successor(n )

library/src/scala/collection/mutable/ListMap.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package mutable
1515

1616
import scala.language.`2.13`
1717
import language.experimental.captureChecking
18-
import scala.annotation.tailrec
18+
import scala.annotation.{tailrec, nowarn}
1919
import scala.collection.generic.DefaultSerializable
2020
import scala.collection.immutable.List
2121

@@ -68,6 +68,7 @@ class ListMap[K, V]
6868
final override def size: Int = siz
6969
override def knownSize: Int = size
7070
override def isEmpty: Boolean = size == 0
71+
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
7172
override protected def stringPrefix = "ListMap"
7273
}
7374

library/src/scala/collection/mutable/OpenHashMap.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ package mutable
1515

1616
import scala.language.`2.13`
1717
import language.experimental.captureChecking
18+
19+
import scala.annotation.nowarn
1820
import java.lang.Integer.numberOfLeadingZeros
1921
import java.util.ConcurrentModificationException
2022
import scala.collection.generic.DefaultSerializable
@@ -304,5 +306,6 @@ class OpenHashMap[Key, Value](initialSize : Int)
304306
this
305307
}
306308

309+
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
307310
override protected def stringPrefix = "OpenHashMap"
308311
}

library/src/scala/runtime/ScalaNumberProxy.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ import scala.language.`2.13`
1717
import scala.collection.immutable
1818
import scala.math.ScalaNumericAnyConversions
1919
import immutable.NumericRange
20-
import Proxy.Typed
2120
import scala.annotation.nowarn
2221

2322
/** Base classes for the Rich* wrappers of the primitive types.
2423
* As with all classes in scala.runtime.*, this is not a supported API.
2524
*/
2625
@nowarn("cat=deprecation")
27-
trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Typed[T] with OrderedProxy[T] {
26+
trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Proxy.Typed[T] with OrderedProxy[T] {
2827
protected implicit def num: Numeric[T]
2928

3029
def doubleValue = num.toDouble(self)
@@ -70,14 +69,14 @@ trait FractionalProxy[T] extends Any with ScalaNumberProxy[T] {
7069
}
7170

7271
@nowarn("cat=deprecation")
73-
trait OrderedProxy[T] extends Any with Ordered[T] with Typed[T] {
72+
trait OrderedProxy[T] extends Any with Ordered[T] with Proxy.Typed[T] {
7473
protected def ord: Ordering[T]
7574

7675
def compare(y: T) = ord.compare(self, y)
7776
}
7877

7978
@nowarn("cat=deprecation")
80-
trait RangedProxy[T] extends Any with Typed[T] {
79+
trait RangedProxy[T] extends Any with Proxy.Typed[T] {
8180
type ResultWithoutStep
8281

8382
def until(end: T): ResultWithoutStep

0 commit comments

Comments
 (0)