Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions library/src/scala/Predef.scala
Copy link
Member Author

Choose a reason for hiding this comment

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

@elidable was deprecated in #23913.

Original file line number Diff line number Diff line change
Expand Up @@ -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, nowarn }
import scala.annotation.meta.{ companionClass, companionMethod }
import scala.annotation.internal.{ RuntimeChecked }
import scala.compiletime.summonFrom
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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")
Expand All @@ -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)
}
Expand Down Expand Up @@ -504,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
*/
Expand Down Expand Up @@ -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]]
*/
Expand Down
12 changes: 5 additions & 7 deletions library/src/scala/collection/immutable/Stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Member Author

Choose a reason for hiding this comment

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

the call to hasNext before makes sure that indeed node is not null. This was an exhaustivity warning (missing case null).

case n: RBNode @uc =>
val r = extract(n)
node = CollisionProofHashMap.successor(n )
Expand Down
3 changes: 2 additions & 1 deletion library/src/scala/collection/mutable/ListMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"
}

Expand Down
3 changes: 3 additions & 0 deletions library/src/scala/collection/mutable/OpenHashMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -304,5 +306,6 @@ class OpenHashMap[Key, Value](initialSize : Int)
this
}

@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
override protected def stringPrefix = "OpenHashMap"
}
7 changes: 3 additions & 4 deletions library/src/scala/runtime/ScalaNumberProxy.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Loading