Skip to content

Commit 84c7e44

Browse files
authored
chore: add transparent modifier to already assumed transparent types (#23104)
`dotc` already assumes that some of the types in stdlib are transparent. We now drop the assumption and add the `transparent` modifier to the source. For reference, the list of assumed transparent types: https://github.com/scala/scala3/blob/5ac8a32b9ab3f92c9086fa27ef279f00255ea358/compiler/src/dotty/tools/dotc/core/Definitions.scala#L2051-L2092
2 parents 3c30c22 + 5931804 commit 84c7e44

37 files changed

+46
-46
lines changed

library/src/scala/AnyVal.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ package scala
5353
* still must allocate a value class instance at runtime. These limitations and circumstances are
5454
* explained in greater detail in the [[https://docs.scala-lang.org/overviews/core/value-classes.html Value Classes and Universal Traits]].
5555
*/
56-
abstract class AnyVal extends Any {
56+
transparent abstract class AnyVal extends Any {
5757
def getClass(): Class[_ <: AnyVal] = null
5858
}

library/src/scala/Product.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package scala
1717
* their subclasses [[scala.Tuple1]] through [[scala.Tuple22]]. In addition,
1818
* all case classes implement `Product` with synthetically generated methods.
1919
*/
20-
trait Product extends Any with Equals {
20+
transparent trait Product extends Any with Equals {
2121
/** The size of this product.
2222
* @return for a product `A(x,,1,,, ..., x,,k,,)`, returns `k`
2323
*/

library/src/scala/collection/BitSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ object BitSet extends SpecificIterableFactory[Int, BitSet] {
8282
}
8383

8484
/** Base implementation type of bitsets */
85-
trait BitSetOps[+C <: BitSet with BitSetOps[C]]
85+
transparent trait BitSetOps[+C <: BitSet with BitSetOps[C]]
8686
extends SortedSetOps[Int, SortedSet, C] { self =>
8787
import BitSetOps._
8888

library/src/scala/collection/IndexedSeq.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ trait IndexedSeq[+A] extends Seq[A]
3232
object IndexedSeq extends SeqFactory.Delegate[IndexedSeq](immutable.IndexedSeq)
3333

3434
/** Base trait for indexed Seq operations */
35-
trait IndexedSeqOps[+A, +CC[_], +C] extends Any with SeqOps[A, CC, C] { self =>
35+
transparent trait IndexedSeqOps[+A, +CC[_], +C] extends Any with SeqOps[A, CC, C] { self =>
3636

3737
def iterator: Iterator[A] = view.iterator
3838

library/src/scala/collection/Iterable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ trait Iterable[+A] extends IterableOnce[A]
131131
* The order in which operations are performed on elements is unspecified
132132
* and may be nondeterministic.
133133
*/
134-
trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with IterableOnceOps[A, CC, C] {
134+
transparent trait IterableOps[+A, +CC[_], +C] extends Any with IterableOnce[A] with IterableOnceOps[A, CC, C] {
135135
/**
136136
* @return This collection as an `Iterable[A]`. No new collection will be built if `this` is already an `Iterable[A]`.
137137
*/

library/src/scala/collection/IterableOnce.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ object IterableOnce {
320320
* @define exactlyOnce
321321
* Each element appears exactly once in the computation.
322322
*/
323-
trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
323+
transparent trait IterableOnceOps[+A, +CC[_], +C] extends Any { this: IterableOnce[A] =>
324324
/////////////////////////////////////////////////////////////// Abstract methods that must be implemented
325325

326326
/** Produces a $coll containing cumulative results of applying the

library/src/scala/collection/LinearSeq.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ trait LinearSeq[+A] extends Seq[A]
3232
object LinearSeq extends SeqFactory.Delegate[LinearSeq](immutable.LinearSeq)
3333

3434
/** Base trait for linear Seq operations */
35-
trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeqOps[A, CC, C]] extends Any with SeqOps[A, CC, C] {
35+
transparent trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeqOps[A, CC, C]] extends Any with SeqOps[A, CC, C] {
3636

3737
/** @inheritdoc
3838
*
@@ -259,7 +259,7 @@ trait LinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with LinearSeq
259259
}
260260
}
261261

262-
trait StrictOptimizedLinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with StrictOptimizedLinearSeqOps[A, CC, C]] extends Any with LinearSeqOps[A, CC, C] with StrictOptimizedSeqOps[A, CC, C] {
262+
transparent trait StrictOptimizedLinearSeqOps[+A, +CC[X] <: LinearSeq[X], +C <: LinearSeq[A] with StrictOptimizedLinearSeqOps[A, CC, C]] extends Any with LinearSeqOps[A, CC, C] with StrictOptimizedSeqOps[A, CC, C] {
263263
// A more efficient iterator implementation than the default LinearSeqIterator
264264
override def iterator: Iterator[A] = new AbstractIterator[A] {
265265
private[this] var current = StrictOptimizedLinearSeqOps.this

library/src/scala/collection/Map.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ trait Map[K, +V]
9898
*/
9999
// Note: the upper bound constraint on CC is useful only to
100100
// erase CC to IterableOps instead of Object
101-
trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
101+
transparent trait MapOps[K, +V, +CC[_, _] <: IterableOps[_, AnyConstr, _], +C]
102102
extends IterableOps[(K, V), Iterable, C]
103103
with PartialFunction[K, V] {
104104

library/src/scala/collection/Seq.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object Seq extends SeqFactory.Delegate[Seq](immutable.Seq)
7474
* @define coll sequence
7575
* @define Coll `Seq`
7676
*/
77-
trait SeqOps[+A, +CC[_], +C] extends Any
77+
transparent trait SeqOps[+A, +CC[_], +C] extends Any
7878
with IterableOps[A, CC, C] { self =>
7979

8080
override def view: SeqView[A] = new SeqView.Id[A](this)

library/src/scala/collection/Set.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ trait Set[A]
8585
* @define coll set
8686
* @define Coll `Set`
8787
*/
88-
trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
88+
transparent trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
8989
extends IterableOps[A, CC, C]
9090
with (A => Boolean) {
9191

0 commit comments

Comments
 (0)