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
2 changes: 1 addition & 1 deletion library/src/scala/collection/Iterator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
// type testing does not discriminate based on origin.
private def compareGap(queue: scala.collection.mutable.Queue[A]) = gap eq queue
override def hashCode() = gap.hashCode()
override def equals(other: Any) = other match {
override def equals(other: Any) = (other: @unchecked) match {
case x: Partner => x.compareGap(gap) && gap.isEmpty
case _ => super.equals(other)
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/Map.scala
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ transparent trait MapOps[K, +V, +CC[_, _] <: IterableOps[?, AnyConstr, ?], +C]
def keySet: Set[K] =
// If we know one of the strict implementations inside this library, simply return LazyKeySet
import MapOps.LazyKeySet
this match
(this: @unchecked) match
case s: SeqMap[K, V] => new LazyKeySet(s)
case s: SortedMap[K, V] => new LazyKeySet(s)
case s: immutable.MapOps[K, V, immutable.Map, immutable.Map[K, V]] => new LazyKeySet(s)
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/Seq.scala
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ transparent trait SeqOps[+A, +CC[_], +C] extends Any
@deprecatedOverriding("Override lastIndexWhere(p, end) instead - lastIndexWhere(p) calls lastIndexWhere(p, Int.MaxValue)", "2.13.0")
def lastIndexWhere(p: A => Boolean): Int = lastIndexWhere(p, Int.MaxValue)

@inline private def toGenericSeq: scala.collection.Seq[A] = this match {
@inline private def toGenericSeq: scala.collection.Seq[A] = (this: @unchecked) match {
case s: scala.collection.Seq[A] => s
case _ => toSeq
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/View.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object View extends IterableFactory[View] {

object Filter {
def apply[A](underlying: Iterable[A]^, p: A => Boolean, isFlipped: Boolean): Filter[A]^{underlying, p} =
underlying match {
(underlying: @unchecked) match {
case filter : Filter[A] if filter.isFlipped == isFlipped => {
val f: Filter[A]^{underlying} = filter.unsafeAssumePure // TODO remove when pattern matching works
val f2: Filter[A]^{f, p} = new Filter(f.underlying, a => f.p(a) && p(a), isFlipped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ trait StreamExtensions {
* [[java.util.stream.IntStream `IntStream`]]).
*/
def asJavaParStream[S <: BaseStream[?, ?], St <: Stepper[?]](implicit s: StreamShape[A, S, St], st: StepperShape[A, St]): S = {
val sStepper = stepper match {
val sStepper = (stepper: @unchecked) match {
case as: (AnyStepper[A] & EfficientSplit) => st.parUnbox(as)
case _ => stepper.asInstanceOf[St]
}
Expand Down
10 changes: 5 additions & 5 deletions library/src/scala/collection/immutable/HashMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ final class HashMap[K, +V] private[immutable] (private[immutable] val rootNode:
newHashMapOrThis(rootNode.removed(key, keyUnimprovedHash, improve(keyUnimprovedHash), 0))
}

override def concat[V1 >: V](that: scala.IterableOnce[(K, V1)]^): HashMap[K, V1] = that match {
override def concat[V1 >: V](that: scala.IterableOnce[(K, V1)]^): HashMap[K, V1] = (that: @unchecked) match {
case hm: HashMap[K, V1] =>
if (isEmpty) hm
else {
Expand Down Expand Up @@ -242,7 +242,7 @@ final class HashMap[K, +V] private[immutable] (private[immutable] val rootNode:
}
}
}
that match {
(that: @unchecked) match {
case thatMap: Map[K, V1] =>
if (thatMap.isEmpty) this
else {
Expand Down Expand Up @@ -391,7 +391,7 @@ final class HashMap[K, +V] private[immutable] (private[immutable] val rootNode:
if (isEmpty) {
this
} else {
keys match {
(keys: @unchecked) match {
case hashSet: HashSet[K] =>
if (hashSet.isEmpty) {
this
Expand Down Expand Up @@ -2207,7 +2207,7 @@ object HashMap extends MapFactory[HashMap] {
EmptyMap.asInstanceOf[HashMap[K, V]]

def from[K, V](source: collection.IterableOnce[(K, V)]^): HashMap[K, V] =
source match {
(source: @unchecked) match {
case hs: HashMap[K, V] => hs
case _ => (newBuilder[K, V] ++= source).result()
}
Expand Down Expand Up @@ -2373,7 +2373,7 @@ private[immutable] final class HashMapBuilder[K, V] extends ReusableBuilder[(K,

override def addAll(xs: IterableOnce[(K, V)]^): this.type = {
ensureUnaliased()
xs match {
(xs: @unchecked) match {
case hm: HashMap[K, V] =>
new ChampBaseIterator[(K, V), MapNode[K, V]](hm.rootNode) {
while(hasNext) {
Expand Down
8 changes: 4 additions & 4 deletions library/src/scala/collection/immutable/HashSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final class HashSet[A] private[immutable](private[immutable] val rootNode: Bitma
}

override def concat(that: IterableOnce[A]^): HashSet[A] =
that match {
(that: @unchecked) match {
case hs: HashSet[A] =>
if (isEmpty) hs
else {
Expand Down Expand Up @@ -308,7 +308,7 @@ final class HashSet[A] private[immutable](private[immutable] val rootNode: Bitma
this
}

override def removedAll(that: IterableOnce[A]^): HashSet[A] = that match {
override def removedAll(that: IterableOnce[A]^): HashSet[A] = (that: @unchecked) match {
case set: scala.collection.Set[A] => diff(set)
case range: Range if range.length > size =>
filter {
Expand Down Expand Up @@ -1940,7 +1940,7 @@ object HashSet extends IterableFactory[HashSet] {
EmptySet.asInstanceOf[HashSet[A]]

def from[A](source: collection.IterableOnce[A]^): HashSet[A] =
source match {
(source: @unchecked) match {
case hs: HashSet[A] => hs
case _ if source.knownSize == 0 => empty[A]
case _ => (newBuilder[A] ++= source).result()
Expand Down Expand Up @@ -2082,7 +2082,7 @@ private[collection] final class HashSetBuilder[A] extends ReusableBuilder[A, Has

override def addAll(xs: IterableOnce[A]^) = {
ensureUnaliased()
xs match {
(xs: @unchecked) match {
case hm: HashSet[A] =>
new ChampBaseIterator[A, SetNode[A]](hm.rootNode) {
while(hasNext) {
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/List.scala
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ sealed abstract class List[+A]

override def prepended[B >: A](elem: B): List[B] = elem :: this

override def prependedAll[B >: A](prefix: collection.IterableOnce[B]^): List[B] = prefix match {
override def prependedAll[B >: A](prefix: collection.IterableOnce[B]^): List[B] = (prefix: @unchecked) match {
case xs: List[B] => xs ::: this
case _ if prefix.knownSize == 0 => this
case b: ListBuffer[B] if this.isEmpty => b.toList
Expand Down
8 changes: 4 additions & 4 deletions library/src/scala/collection/immutable/ListMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ object ListMap extends MapFactory[ListMap] {
private object EmptyListMap extends ListMap[Any, Nothing]

def from[K, V](it: collection.IterableOnce[(K, V)]^): ListMap[K, V] =
it match {
(it: @unchecked) match {
case lm: ListMap[K, V] => lm
case lhm: collection.mutable.LinkedHashMap[K, V] =>
// by directly iterating through LinkedHashMap entries, we save creating intermediate tuples for each
Expand Down Expand Up @@ -305,7 +305,7 @@ private[immutable] final class ListMapBuilder[K, V] extends mutable.ReusableBuil
override def addOne(elem: (K, V)): this.type = addOne(elem._1, elem._2)

@tailrec
private def insertValueAtKeyReturnFound(m: ListMap[K, V], key: K, value: V): Boolean = m match {
private def insertValueAtKeyReturnFound(m: ListMap[K, V], key: K, value: V): Boolean = (m: @unchecked) match {
case n: ListMap.Node[K, V] =>
if (n.key == key) {
n._value = value
Expand All @@ -330,7 +330,7 @@ private[immutable] final class ListMapBuilder[K, V] extends mutable.ReusableBuil
if (isAliased) {
super.addAll(xs)
} else if (underlying.nonEmpty) {
xs match {
(xs: @unchecked) match {
case m: collection.Map[K, V] =>
// if it is a map, then its keys will not collide with themselves.
// therefor we only need to check the already-existing elements for collisions.
Expand All @@ -350,7 +350,7 @@ private[immutable] final class ListMapBuilder[K, V] extends mutable.ReusableBuil
case _ =>
super.addAll(xs)
}
} else xs match {
} else (xs: @unchecked) match {
case lhm: collection.mutable.LinkedHashMap[K, V] =>
// special-casing LinkedHashMap avoids creating of Iterator and tuples for each key-value
var firstEntry = lhm._firstEntry
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/ListSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ sealed class ListSet[A]
object ListSet extends IterableFactory[ListSet] {

def from[E](it: scala.collection.IterableOnce[E]^): ListSet[E] =
it match {
(it: @unchecked) match {
case ls: ListSet[E] => ls
case _ if it.knownSize == 0 => empty[E]
case _ => (newBuilder[E] ++= it).result()
Expand Down
4 changes: 2 additions & 2 deletions library/src/scala/collection/immutable/Map.scala
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ object Map extends MapFactory[Map] {
def empty[K, V]: Map[K, V] = EmptyMap.asInstanceOf[Map[K, V]]

def from[K, V](it: IterableOnce[(K, V)]^): Map[K, V] =
it match {
(it: @unchecked) match {
case it: Iterable[_] if it.isEmpty => empty[K, V]
// Since IterableOnce[(K, V)] launders the variance of K,
// identify only our implementations which can be soundly substituted.
Expand Down Expand Up @@ -253,7 +253,7 @@ object Map extends MapFactory[Map] {
override def valuesIterator: Iterator[Nothing] = Iterator.empty
def updated [V1] (key: Any, value: V1): Map[Any, V1] = new Map1(key, value)
def removed(key: Any): Map[Any, Nothing] = this
override def concat[V2 >: Nothing](suffix: IterableOnce[(Any, V2)]^): Map[Any, V2] = suffix match {
override def concat[V2 >: Nothing](suffix: IterableOnce[(Any, V2)]^): Map[Any, V2] = (suffix: @unchecked) match {
case m: immutable.Map[Any, V2] => m
case _ => super.concat(suffix)
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/SeqMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object SeqMap extends MapFactory[SeqMap] {
def empty[K, V]: SeqMap[K, V] = EmptySeqMap.asInstanceOf[SeqMap[K, V]]

def from[K, V](it: collection.IterableOnce[(K, V)]^): SeqMap[K, V] =
it match {
(it: @unchecked) match {
//case sm: SeqMap[K, V] => sm
case m: ListMap[K, V] => m
case m: TreeSeqMap[K, V] => m
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/Set.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object Set extends IterableFactory[Set] {
def empty[A]: Set[A] = EmptySet.asInstanceOf[Set[A]]

def from[E](it: collection.IterableOnce[E]^): Set[E] =
it match {
(it: @unchecked) match {
case _ if it.knownSize == 0 => empty[E]
// Since IterableOnce[E] launders the variance of E,
// identify only our implementations which can be soundly substituted.
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/SortedMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ transparent trait StrictOptimizedSortedMapOps[K, +V, +CC[X, +Y] <: Map[X, Y] & S
@SerialVersionUID(3L)
object SortedMap extends SortedMapFactory.Delegate[SortedMap](TreeMap) {

override def from[K: Ordering, V](it: IterableOnce[(K, V)]^): SortedMap[K, V] = it match {
override def from[K: Ordering, V](it: IterableOnce[(K, V)]^): SortedMap[K, V] = (it: @unchecked) match {
case sm: SortedMap[K, V] if Ordering[K] == sm.ordering => sm
case _ => super.from(it)
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/SortedSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ transparent trait StrictOptimizedSortedSetOps[A, +CC[X] <: SortedSet[X], +C <: S
*/
@SerialVersionUID(3L)
object SortedSet extends SortedIterableFactory.Delegate[SortedSet](TreeSet) {
override def from[E: Ordering](it: IterableOnce[E]^): SortedSet[E] = it match {
override def from[E: Ordering](it: IterableOnce[E]^): SortedSet[E] = (it: @unchecked) match {
case ss: SortedSet[E] if Ordering[E] == ss.ordering => ss
case _ => super.from(it)
}
Expand Down
6 changes: 3 additions & 3 deletions library/src/scala/collection/immutable/TreeMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ final class TreeMap[K, +V] private (private val tree: RB.Tree[K, V] | Null)(impl
adder.finalTree
})

override def removedAll(keys: IterableOnce[K]^): TreeMap[K, V] = keys match {
override def removedAll(keys: IterableOnce[K]^): TreeMap[K, V] = (keys: @unchecked) match {
case ts: TreeSet[K] if ordering == ts.ordering =>
newMapOrSelf(RB.difference(tree, ts.tree))
case _ => super.removedAll(keys)
Expand Down Expand Up @@ -313,7 +313,7 @@ object TreeMap extends SortedMapFactory[TreeMap] {
def empty[K : Ordering, V]: TreeMap[K, V] = new TreeMap()

def from[K, V](it: IterableOnce[(K, V)]^)(implicit ordering: Ordering[K]): TreeMap[K, V] =
it match {
(it: @unchecked) match {
case tm: TreeMap[K, V] if ordering == tm.ordering => tm
case sm: scala.collection.SortedMap[K, V] if ordering == sm.ordering =>
new TreeMap[K, V](RB.fromOrderedEntries(sm.iterator, sm.size))
Expand Down Expand Up @@ -357,7 +357,7 @@ object TreeMap extends SortedMapFactory[TreeMap] {
}

override def addAll(xs: IterableOnce[(K, V)]^): this.type = {
xs match {
(xs: @unchecked) match {
// TODO consider writing a mutable-safe union for TreeSet/TreeMap builder ++=
// for the moment we have to force immutability before the union
// which will waste some time and space
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/TreeSeqMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] {
}.asInstanceOf[TreeSeqMap[K, V]]

def from[K, V](it: collection.IterableOnce[(K, V)]^): TreeSeqMap[K, V] =
it match {
(it: @unchecked) match {
case om: TreeSeqMap[K, V] => om
case _ => (newBuilder[K, V] ++= it).result()
}
Expand Down
8 changes: 4 additions & 4 deletions library/src/scala/collection/immutable/TreeSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ final class TreeSet[A] private[immutable] (private[immutable] val tree: RB.Tree[
newSetOrSelf(RB.delete(tree, elem))

override def concat(that: collection.IterableOnce[A]^): TreeSet[A] = {
val t = that match {
val t = (that: @unchecked) match {
case ts: TreeSet[A] if ordering == ts.ordering =>
RB.union(tree, ts.tree)
case _ =>
Expand All @@ -186,7 +186,7 @@ final class TreeSet[A] private[immutable] (private[immutable] val tree: RB.Tree[
newSetOrSelf(t)
}

override def removedAll(that: IterableOnce[A]^): TreeSet[A] = that match {
override def removedAll(that: IterableOnce[A]^): TreeSet[A] = (that: @unchecked) match {
case ts: TreeSet[A] if ordering == ts.ordering =>
newSetOrSelf(RB.difference(tree, ts.tree))
case _ =>
Expand Down Expand Up @@ -243,7 +243,7 @@ object TreeSet extends SortedIterableFactory[TreeSet] {
def empty[A: Ordering]: TreeSet[A] = new TreeSet[A]

def from[E](it: scala.collection.IterableOnce[E]^)(implicit ordering: Ordering[E]): TreeSet[E] =
it match {
(it: @unchecked) match {
case ts: TreeSet[E] if ordering == ts.ordering => ts
case ss: scala.collection.SortedSet[E] if ordering == ss.ordering =>
new TreeSet[E](RB.fromOrderedKeys(ss.iterator, ss.size))
Expand Down Expand Up @@ -273,7 +273,7 @@ object TreeSet extends SortedIterableFactory[TreeSet] {
}

override def addAll(xs: IterableOnce[A]^): this.type = {
xs match {
(xs: @unchecked) match {
// TODO consider writing a mutable-safe union for TreeSet/TreeMap builder ++=
// for the moment we have to force immutability before the union
// which will waste some time and space
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/immutable/VectorMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ object VectorMap extends MapFactory[VectorMap] {
def empty[K, V]: VectorMap[K, V] = EmptyMap.asInstanceOf[VectorMap[K, V]]

def from[K, V](it: collection.IterableOnce[(K, V)]^): VectorMap[K, V] =
it match {
(it: @unchecked) match {
case vm: VectorMap[K, V] => vm
case _ => (newBuilder[K, V] ++= it).result()
}
Expand Down
4 changes: 2 additions & 2 deletions library/src/scala/collection/mutable/HashMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
override def addAll(xs: IterableOnce[(K, V)]^): this.type = {
sizeHint(xs)

xs match {
(xs: @unchecked) match {
case hm: immutable.HashMap[K, V] =>
hm.foreachWithHash((k, v, h) => put0(k, v, improveHash(h), getOld = false))
this
Expand Down Expand Up @@ -193,7 +193,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
return this
}

xs match {
(xs: @unchecked) match {
case hs: immutable.HashSet[K] =>
hs.foreachWithHashWhile { (k, h) =>
remove0(k, improveHash(h))
Expand Down
4 changes: 2 additions & 2 deletions library/src/scala/collection/mutable/HashSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)

override def addAll(xs: IterableOnce[A]^): this.type = {
sizeHint(xs, delta = 0)
xs match {
(xs: @unchecked) match {
case hs: immutable.HashSet[A] =>
hs.foreachWithHash((k, h) => addElem(k, improveHash(h)))
this
Expand All @@ -122,7 +122,7 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
return this
}

xs match {
(xs: @unchecked) match {
case hs: immutable.HashSet[A] =>
hs.foreachWithHashWhile { (k, h) =>
remove(k, improveHash(h))
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/collection/mutable/TreeSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ object TreeSet extends SortedIterableFactory[TreeSet] {
def empty[A : Ordering]: TreeSet[A] = new TreeSet[A]()

def from[E](it: IterableOnce[E]^)(implicit ordering: Ordering[E]): TreeSet[E] =
it match {
(it: @unchecked) match {
case ts: TreeSet[E] if ordering == ts.ordering =>
new TreeSet[E](ts.tree.treeCopy())
case ss: scala.collection.SortedSet[E] if ordering == ss.ordering =>
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/jdk/AnyAccumulator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ object AnyAccumulator extends collection.SeqFactory[AnyAccumulator] {
/** A `BiConsumer` that merges `AnyAccumulator`s, suitable for use with `java.util.stream.Stream`'s `collect` method. */
def merger[A]: jf.BiConsumer[AnyAccumulator[A], AnyAccumulator[A]] = (a1: AnyAccumulator[A], a2: AnyAccumulator[A]) => a1 drain a2

def from[A](source: IterableOnce[A]): AnyAccumulator[A] = source match {
def from[A](source: IterableOnce[A]): AnyAccumulator[A] = (source: @unchecked) match {
case acc: AnyAccumulator[A] => acc
case _ => new AnyAccumulator[A].addAll(source)
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/jdk/javaapi/FutureConverters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object FutureConverters {
* CompletableFuture interface
*/
def asJava[T](f: Future[T]): CompletionStage[T] = {
f match {
(f: @unchecked) match {
case p: P[T] => p.wrapped
// in theory not safe (could be `class C extends Future[A] with CompletionStage[B]`):
case c: CompletionStage[T @unchecked] => c
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/util/Properties.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private[scala] trait PropertiesTrait {

/** System.console.isTerminal, or just check for null console on JDK < 22 */
private[scala] lazy val consoleIsTerminal: Boolean = {
import language.reflectiveCalls
import scala.reflect.Selectable.reflectiveSelectable
val console = System.console
def isTerminal: Boolean =
try console.asInstanceOf[{ def isTerminal(): Boolean }].isTerminal()
Expand Down
2 changes: 1 addition & 1 deletion sbt-bridge/test/xsbt/ScalaCompilerForUnitTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class ScalaCompilerForUnitTesting {
val virtualSrcFiles = srcFiles.toArray
val classesOutputPath = classesOutput.getAbsolutePath()
val output = new SingleOutput:
def getOutputDirectory() = classesOutput
def getOutputDirectory(): File = classesOutput

val maybeSourcePath = if extraFiles.isEmpty then Nil else List("-sourcepath", temp.getAbsolutePath.toString)

Expand Down
Loading