Skip to content

Commit df93319

Browse files
committed
chore: drop old stdlib plugin in favour of internal project
1 parent 6896fe3 commit df93319

26 files changed

+7221
-158
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ val `scala3-compiler` = Build.`scala3-compiler`
55
val `scala3-compiler-bootstrapped` = Build.`scala3-compiler-bootstrapped`
66
val `scala3-library` = Build.`scala3-library`
77
val `scala3-library-bootstrapped` = Build.`scala3-library-bootstrapped`
8+
val `scala-library-internal` = Build.`scala-library-internal`
89
val `scala3-library-bootstrappedJS` = Build.`scala3-library-bootstrappedJS`
910
val `scala3-sbt-bridge` = Build.`scala3-sbt-bridge`
1011
val `scala3-sbt-bridge-tests` = Build.`scala3-sbt-bridge-tests`
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package scala
14+
15+
/** `AnyVal` is the root class of all ''value types'', which describe values
16+
* not implemented as objects in the underlying host system. Value classes
17+
* are specified in Scala Language Specification, section 12.2.
18+
*
19+
* The standard implementation includes nine `AnyVal` subtypes:
20+
*
21+
* [[scala.Double]], [[scala.Float]], [[scala.Long]], [[scala.Int]], [[scala.Char]],
22+
* [[scala.Short]], and [[scala.Byte]] are the ''numeric value types''.
23+
*
24+
* [[scala.Unit]] and [[scala.Boolean]] are the ''non-numeric value types''.
25+
*
26+
* Other groupings:
27+
*
28+
* - The ''subrange types'' are [[scala.Byte]], [[scala.Short]], and [[scala.Char]].
29+
* - The ''integer types'' include the subrange types as well as [[scala.Int]] and [[scala.Long]].
30+
* - The ''floating point types'' are [[scala.Float]] and [[scala.Double]].
31+
*
32+
* A subclass of `AnyVal` is called a ''user-defined value class''
33+
* and is treated specially by the compiler. Properly-defined user value classes provide a way
34+
* to improve performance on user-defined types by avoiding object allocation at runtime, and by
35+
* replacing virtual method invocations with static method invocations.
36+
*
37+
* User-defined value classes which avoid object allocation...
38+
*
39+
* - must have a single `val` parameter that is the underlying runtime representation.
40+
* - can define `def`s, but no `val`s, `var`s, or nested `trait`s, `class`es or `object`s.
41+
* - typically extend no other trait apart from `AnyVal`.
42+
* - cannot be used in type tests or pattern matching.
43+
* - may not override `equals` or `hashCode` methods.
44+
*
45+
* A minimal example:
46+
* {{{
47+
* class Wrapper(val underlying: Int) extends AnyVal {
48+
* def foo: Wrapper = new Wrapper(underlying * 19)
49+
* }
50+
* }}}
51+
*
52+
* It's important to note that user-defined value classes are limited, and in some circumstances,
53+
* still must allocate a value class instance at runtime. These limitations and circumstances are
54+
* explained in greater detail in the [[https://docs.scala-lang.org/overviews/core/value-classes.html Value Classes and Universal Traits]].
55+
*/
56+
abstract class AnyVal extends Any {
57+
def getClass(): Class[_ <: AnyVal] = null
58+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
// GENERATED CODE: DO NOT EDIT.
14+
// genprod generated these sources at: 2022-01-17T20:47:12.170348200Z
15+
16+
package scala
17+
18+
19+
/** A function of 0 parameters.
20+
*
21+
* In the following example, the definition of `greeting` is
22+
* shorthand, conceptually, for the anonymous class definition
23+
* `anonfun0`, although the implementation details of how the
24+
* function value is constructed may differ:
25+
*
26+
* {{{
27+
* object Main extends App {
28+
* val name = "world"
29+
* val greeting = () => s"hello, $name"
30+
*
31+
* val anonfun0 = new Function0[String] {
32+
* def apply(): String = s"hello, $name"
33+
* }
34+
* assert(greeting() == anonfun0())
35+
* }
36+
* }}}
37+
*/
38+
trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef { self =>
39+
/** Apply the body of this function to the arguments.
40+
* @return the result of function application.
41+
*/
42+
def apply(): R
43+
44+
override def toString(): String = "<function0>"
45+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp.
14+
15+
package scala
16+
17+
18+
object Function1 {
19+
20+
implicit final class UnliftOps[A, B] private[Function1](private val f: A => Option[B]) extends AnyVal {
21+
/** Converts an optional function to a partial function.
22+
*
23+
* @example Unlike [[Function.unlift]], this [[UnliftOps.unlift]] method can be used in extractors.
24+
* {{{
25+
* val of: Int => Option[String] = { i =>
26+
* if (i == 2) {
27+
* Some("matched by an optional function")
28+
* } else {
29+
* None
30+
* }
31+
* }
32+
*
33+
* util.Random.nextInt(4) match {
34+
* case of.unlift(m) => // Convert an optional function to a pattern
35+
* println(m)
36+
* case _ =>
37+
* println("Not matched")
38+
* }
39+
* }}}
40+
*/
41+
def unlift: PartialFunction[A, B] = Function.unlift(f)
42+
}
43+
44+
}
45+
46+
/** A function of 1 parameter.
47+
*
48+
* In the following example, the definition of `succ` is
49+
* shorthand, conceptually, for the anonymous class definition
50+
* `anonfun1`, although the implementation details of how the
51+
* function value is constructed may differ:
52+
*
53+
* {{{
54+
* object Main extends App {
55+
* val succ = (x: Int) => x + 1
56+
* val anonfun1 = new Function1[Int, Int] {
57+
* def apply(x: Int): Int = x + 1
58+
* }
59+
* assert(succ(0) == anonfun1(0))
60+
* }
61+
* }}}
62+
*
63+
* Note that the difference between `Function1` and [[scala.PartialFunction]]
64+
* is that the latter can specify inputs which it will not handle.
65+
*/
66+
@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.")
67+
trait Function1[@specialized(Specializable.Arg) -T1, @specialized(Specializable.Return) +R] extends AnyRef { self =>
68+
/** Apply the body of this function to the argument.
69+
* @return the result of function application.
70+
*/
71+
def apply(v1: T1): R
72+
73+
/** Composes two instances of `Function1` in a new `Function1`, with this function applied last.
74+
*
75+
* @tparam A the type to which function `g` can be applied
76+
* @param g a function A => T1
77+
* @return a new function `f` such that `f(x) == apply(g(x))`
78+
*/
79+
@annotation.unspecialized def compose[A](g: A => T1): A => R = { x => apply(g(x)) }
80+
81+
/** Composes two instances of `Function1` in a new `Function1`, with this function applied first.
82+
*
83+
* @tparam A the result type of function `g`
84+
* @param g a function R => A
85+
* @return a new function `f` such that `f(x) == g(apply(x))`
86+
*/
87+
@annotation.unspecialized def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) }
88+
89+
override def toString(): String = "<function1>"
90+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp.
14+
15+
package scala
16+
17+
18+
/** A function of 2 parameters.
19+
*
20+
* In the following example, the definition of `max` is
21+
* shorthand, conceptually, for the anonymous class definition
22+
* `anonfun2`, although the implementation details of how the
23+
* function value is constructed may differ:
24+
*
25+
* {{{
26+
* object Main extends App {
27+
* val max = (x: Int, y: Int) => if (x < y) y else x
28+
*
29+
* val anonfun2 = new Function2[Int, Int, Int] {
30+
* def apply(x: Int, y: Int): Int = if (x < y) y else x
31+
* }
32+
* assert(max(0, 1) == anonfun2(0, 1))
33+
* }
34+
* }}}
35+
*/
36+
trait Function2[@specialized(Specializable.Args) -T1, @specialized(Specializable.Args) -T2, @specialized(Specializable.Return) +R] extends AnyRef { self =>
37+
/** Apply the body of this function to the arguments.
38+
* @return the result of function application.
39+
*/
40+
def apply(v1: T1, v2: T2): R
41+
/** Creates a curried version of this function.
42+
*
43+
* @return a function `f` such that `f(x1)(x2) == apply(x1, x2)`
44+
*/
45+
@annotation.unspecialized def curried: T1 => T2 => R = {
46+
(x1: T1) => (x2: T2) => apply(x1, x2)
47+
}
48+
/** Creates a tupled version of this function: instead of 2 arguments,
49+
* it accepts a single [[scala.Tuple2]] argument.
50+
*
51+
* @return a function `f` such that `f((x1, x2)) == f(Tuple2(x1, x2)) == apply(x1, x2)`
52+
*/
53+
54+
@annotation.unspecialized def tupled: ((T1, T2)) => R = {
55+
case ((x1, x2)) => apply(x1, x2)
56+
}
57+
override def toString(): String = "<function2>"
58+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp.
14+
15+
package scala
16+
17+
object Product1 {
18+
def unapply[T1](x: Product1[T1]): Option[Product1[T1]] =
19+
Some(x)
20+
}
21+
22+
/** Product1 is a Cartesian product of 1 component.
23+
*/
24+
trait Product1[@specialized(Int, Long, Double) +T1] extends Any with Product {
25+
/** The arity of this product.
26+
* @return 1
27+
*/
28+
override def productArity: Int = 1
29+
30+
31+
/** Returns the n-th projection of this product if 0 <= n < productArity,
32+
* otherwise throws an `IndexOutOfBoundsException`.
33+
*
34+
* @param n number of the projection to be returned
35+
* @return same as `._(n+1)`, for example `productElement(0)` is the same as `._1`.
36+
* @throws IndexOutOfBoundsException if the `n` is out of range(n < 0 || n >= 1).
37+
*/
38+
39+
@throws(classOf[IndexOutOfBoundsException])
40+
override def productElement(n: Int): Any = n match {
41+
case 0 => _1
42+
case _ => throw new IndexOutOfBoundsException(s"$n is out of bounds (min 0, max 0)")
43+
}
44+
45+
/** A projection of element 1 of this Product.
46+
* @return A projection of element 1.
47+
*/
48+
def _1: T1
49+
50+
51+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
// GENERATED CODE: DO NOT EDIT. See scala.Function0 for timestamp.
14+
15+
package scala
16+
17+
object Product2 {
18+
def unapply[T1, T2](x: Product2[T1, T2]): Option[Product2[T1, T2]] =
19+
Some(x)
20+
}
21+
22+
/** Product2 is a Cartesian product of 2 components.
23+
*/
24+
trait Product2[@specialized(Int, Long, Double) +T1, @specialized(Int, Long, Double) +T2] extends Any with Product {
25+
/** The arity of this product.
26+
* @return 2
27+
*/
28+
override def productArity: Int = 2
29+
30+
31+
/** Returns the n-th projection of this product if 0 <= n < productArity,
32+
* otherwise throws an `IndexOutOfBoundsException`.
33+
*
34+
* @param n number of the projection to be returned
35+
* @return same as `._(n+1)`, for example `productElement(0)` is the same as `._1`.
36+
* @throws IndexOutOfBoundsException if the `n` is out of range(n < 0 || n >= 2).
37+
*/
38+
39+
@throws(classOf[IndexOutOfBoundsException])
40+
override def productElement(n: Int): Any = n match {
41+
case 0 => _1
42+
case 1 => _2
43+
case _ => throw new IndexOutOfBoundsException(s"$n is out of bounds (min 0, max 1)")
44+
}
45+
46+
/** A projection of element 1 of this Product.
47+
* @return A projection of element 1.
48+
*/
49+
def _1: T1
50+
/** A projection of element 2 of this Product.
51+
* @return A projection of element 2.
52+
*/
53+
def _2: T2
54+
55+
56+
}

0 commit comments

Comments
 (0)