Skip to content

Commit 1f13619

Browse files
natsukagamiLinyxus
andauthored
Port Capture-checked Scala 2 collections (#23769)
New final class `collection.immutable.LazyListIterable[A]`, implements Iterable and IterableOps. `LazyList` and `Stream` are not capture-checked. Note added to `LazyList`. --------- Co-authored-by: Yichen Xu <[email protected]>
1 parent c140894 commit 1f13619

File tree

173 files changed

+2860
-1093
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+2860
-1093
lines changed

library-js/src/scala/Array.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
package scala
1414

15+
import language.experimental.captureChecking
16+
1517
//import scala.collection.generic._
1618
import scala.collection.{Factory, immutable, mutable}
1719
import mutable.ArrayBuilder
@@ -61,7 +63,7 @@ object Array {
6163
implicit def toFactory[A : ClassTag](dummy: Array.type): Factory[A, Array[A]] = new ArrayFactory(dummy)
6264
@SerialVersionUID(3L)
6365
private class ArrayFactory[A : ClassTag](dummy: Array.type) extends Factory[A, Array[A]] with Serializable {
64-
def fromSpecific(it: IterableOnce[A]): Array[A] = Array.from[A](it)
66+
def fromSpecific(it: IterableOnce[A]^): Array[A] = Array.from[A](it)
6567
def newBuilder: mutable.Builder[A, Array[A]] = Array.newBuilder[A]
6668
}
6769

@@ -70,7 +72,7 @@ object Array {
7072
*/
7173
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T](using t)
7274

73-
def from[A : ClassTag](it: IterableOnce[A]): Array[A] = {
75+
def from[A: ClassTag](it: IterableOnce[A]^): Array[A] = {
7476
val n = it.knownSize
7577
if (n > -1) {
7678
val elements = new Array[A](n)
@@ -656,7 +658,7 @@ object Array {
656658
* @define collectExample
657659
* @define undefinedorder
658660
*/
659-
final class Array[T](_length: Int) extends java.io.Serializable with java.lang.Cloneable {
661+
final class Array[T](_length: Int) extends java.io.Serializable with java.lang.Cloneable { self =>
660662

661663
/** The length of the array */
662664
def length: Int = throw new Error()

library/src/scala/Array.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package scala
1414

1515
import scala.language.`2.13`
16+
import language.experimental.captureChecking
1617

1718
//import scala.collection.generic._
1819
import scala.collection.{Factory, immutable, mutable}
@@ -49,7 +50,7 @@ object Array {
4950
implicit def toFactory[A : ClassTag](dummy: Array.type): Factory[A, Array[A]] = new ArrayFactory(dummy)
5051
@SerialVersionUID(3L)
5152
private class ArrayFactory[A : ClassTag](dummy: Array.type) extends Factory[A, Array[A]] with Serializable {
52-
def fromSpecific(it: IterableOnce[A]): Array[A] = Array.from[A](it)
53+
def fromSpecific(it: IterableOnce[A]^): Array[A] = Array.from[A](it)
5354
def newBuilder: mutable.Builder[A, Array[A]] = Array.newBuilder[A]
5455
}
5556

@@ -71,7 +72,7 @@ object Array {
7172
* @param it the iterable collection
7273
* @return an array consisting of elements of the iterable collection
7374
*/
74-
def from[A : ClassTag](it: IterableOnce[A]): Array[A] = it match {
75+
def from[A : ClassTag](it: IterableOnce[A]^): Array[A] = it match {
7576
case it: Iterable[A] => it.toArray[A]
7677
case _ => it.iterator.toArray[A]
7778
}
@@ -659,7 +660,7 @@ object Array {
659660
* @define collectExample
660661
* @define undefinedorder
661662
*/
662-
final class Array[T](_length: Int) extends java.io.Serializable with java.lang.Cloneable {
663+
final class Array[T](_length: Int) extends java.io.Serializable with java.lang.Cloneable { self: Array[T] =>
663664

664665
/** The length of the array */
665666
def length: Int = throw new Error()

library/src/scala/Boolean.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ final abstract class Boolean private extends AnyVal {
114114

115115
object Boolean extends AnyValCompanion {
116116

117-
/** Transform a value type into a boxed reference type.
117+
/** Transforms a value type into a boxed reference type.
118118
*
119119
* Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToBoolean`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
120120
*
@@ -123,7 +123,7 @@ object Boolean extends AnyValCompanion {
123123
*/
124124
def box(x: Boolean): java.lang.Boolean = ???
125125

126-
/** Transform a boxed type into a value type. Note that this
126+
/** Transforms a boxed type into a value type. Note that this
127127
* method is not typesafe: it accepts any Object, but will throw
128128
* an exception if the argument is not a java.lang.Boolean.
129129
*

library/src/scala/Byte.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ object Byte extends AnyValCompanion {
455455
/** The largest value representable as a Byte. */
456456
final val MaxValue = java.lang.Byte.MAX_VALUE
457457

458-
/** Transform a value type into a boxed reference type.
458+
/** Transforms a value type into a boxed reference type.
459459
*
460460
* Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToByte`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
461461
*
@@ -464,7 +464,7 @@ object Byte extends AnyValCompanion {
464464
*/
465465
def box(x: Byte): java.lang.Byte = ???
466466

467-
/** Transform a boxed type into a value type. Note that this
467+
/** Transforms a boxed type into a value type. Note that this
468468
* method is not typesafe: it accepts any Object, but will throw
469469
* an exception if the argument is not a java.lang.Byte.
470470
*

library/src/scala/Char.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ object Char extends AnyValCompanion {
455455
/** The largest value representable as a Char. */
456456
final val MaxValue = java.lang.Character.MAX_VALUE
457457

458-
/** Transform a value type into a boxed reference type.
458+
/** Transforms a value type into a boxed reference type.
459459
*
460460
* Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToCharacter`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
461461
*
@@ -464,7 +464,7 @@ object Char extends AnyValCompanion {
464464
*/
465465
def box(x: Char): java.lang.Character = ???
466466

467-
/** Transform a boxed type into a value type. Note that this
467+
/** Transforms a boxed type into a value type. Note that this
468468
* method is not typesafe: it accepts any Object, but will throw
469469
* an exception if the argument is not a java.lang.Character.
470470
*

library/src/scala/Double.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ object Double extends AnyValCompanion {
230230
/** The largest finite positive number representable as a Double. */
231231
final val MaxValue = java.lang.Double.MAX_VALUE
232232

233-
/** Transform a value type into a boxed reference type.
233+
/** Transforms a value type into a boxed reference type.
234234
*
235235
* Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToDouble`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
236236
*
@@ -239,7 +239,7 @@ object Double extends AnyValCompanion {
239239
*/
240240
def box(x: Double): java.lang.Double = ???
241241

242-
/** Transform a boxed type into a value type. Note that this
242+
/** Transforms a boxed type into a value type. Note that this
243243
* method is not typesafe: it accepts any Object, but will throw
244244
* an exception if the argument is not a java.lang.Double.
245245
*

library/src/scala/Float.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ object Float extends AnyValCompanion {
230230
/** The largest finite positive number representable as a Float. */
231231
final val MaxValue = java.lang.Float.MAX_VALUE
232232

233-
/** Transform a value type into a boxed reference type.
233+
/** Transforms a value type into a boxed reference type.
234234
*
235235
* Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToFloat`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
236236
*
@@ -239,7 +239,7 @@ object Float extends AnyValCompanion {
239239
*/
240240
def box(x: Float): java.lang.Float = ???
241241

242-
/** Transform a boxed type into a value type. Note that this
242+
/** Transforms a boxed type into a value type. Note that this
243243
* method is not typesafe: it accepts any Object, but will throw
244244
* an exception if the argument is not a java.lang.Float.
245245
*

library/src/scala/Function0.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
// GENERATED CODE: DO NOT EDIT.
14-
// genprod generated these sources at: 2022-01-17T20:47:12.170348200Z
14+
// genprod generated these sources at: 2025-08-11T16:44:44.712777821Z
1515

1616
package scala
1717

@@ -36,7 +36,7 @@ import scala.language.`2.13`
3636
* }
3737
* }}}
3838
*/
39-
trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef { self =>
39+
trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef {
4040
/** Apply the body of this function to the arguments.
4141
* @return the result of function application.
4242
*/

library/src/scala/Function1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object Function1 {
6565
* is that the latter can specify inputs which it will not handle.
6666
*/
6767
@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.")
68-
trait Function1[@specialized(Specializable.Arg) -T1, @specialized(Specializable.Return) +R] extends AnyRef { self =>
68+
trait Function1[@specialized(Specializable.Arg) -T1, @specialized(Specializable.Return) +R] extends AnyRef {
6969
/** Apply the body of this function to the argument.
7070
* @return the result of function application.
7171
*/

library/src/scala/Function10.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import scala.language.`2.13`
1919
/** A function of 10 parameters.
2020
*
2121
*/
22-
trait Function10[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends AnyRef { self =>
22+
trait Function10[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends AnyRef {
2323
/** Apply the body of this function to the arguments.
2424
* @return the result of function application.
2525
*/
@@ -29,7 +29,7 @@ trait Function10[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, +R] extends
2929
* @return a function `f` such that `f(x1)(x2)(x3)(x4)(x5)(x6)(x7)(x8)(x9)(x10) == apply(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)`
3030
*/
3131
@annotation.unspecialized def curried: T1 => T2 => T3 => T4 => T5 => T6 => T7 => T8 => T9 => T10 => R = {
32-
(x1: T1) => ((x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10) => self.apply(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)).curried
32+
(x1: T1) => ((x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10) => this.apply(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)).curried
3333
}
3434
/** Creates a tupled version of this function: instead of 10 arguments,
3535
* it accepts a single [[scala.Tuple10]] argument.

0 commit comments

Comments
 (0)