Skip to content

Commit cc3bada

Browse files
committed
Removes AnyRef specialization from library
As discussed in #999, #1025 and https://groups.google.com/forum/?hl=en&fromgroups#!topic/scala-internals/5P5TS9ZWe_w instrumented.jar is generated from the current source, there's no need for a bootstrap commit. Review by @paulp.
1 parent 86c159a commit cc3bada

File tree

10 files changed

+23
-21
lines changed

10 files changed

+23
-21
lines changed

src/build/genprod.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
** |/ **
77
\* */
88

9+
import language.postfixOps
10+
911
/** This program generates the ProductN, TupleN, FunctionN,
1012
* and AbstractFunctionN, where 0 <= N <= MAX_ARITY.
1113
*
@@ -75,7 +77,7 @@ package %s
7577

7678
if (args.length != 1) {
7779
println("please give path of output directory")
78-
exit(-1)
80+
sys.exit(-1)
7981
}
8082
val out = args(0)
8183
def writeFile(node: scala.xml.Node) {
@@ -96,7 +98,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz */
9698

9799
object FunctionZero extends Function(0) {
98100
override def genprodString = "\n// genprod generated these sources at: " + new java.util.Date()
99-
override def covariantSpecs = "@specialized "
101+
override def covariantSpecs = "@specialized(Specializable.Primitives) "
100102
override def descriptiveComment = " " + functionNTemplate.format("javaVersion", "anonfun0",
101103
"""
102104
* val javaVersion = () => sys.props("java.version")
@@ -111,8 +113,8 @@ object FunctionZero extends Function(0) {
111113

112114
object FunctionOne extends Function(1) {
113115
override def classAnnotation = "@annotation.implicitNotFound(msg = \"No implicit view available from ${T1} => ${R}.\")\n"
114-
override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) "
115-
override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) "
116+
override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) "
117+
override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) "
116118

117119
override def descriptiveComment = " " + functionNTemplate.format("succ", "anonfun1",
118120
"""
@@ -169,7 +171,7 @@ object Function {
169171

170172
class Function(val i: Int) extends Group("Function") with Arity {
171173
def descriptiveComment = ""
172-
def functionNTemplate =
174+
def functionNTemplate =
173175
"""
174176
* In the following example, the definition of %s is a
175177
* shorthand for the anonymous class definition %s:
@@ -226,7 +228,7 @@ class Function(val i: Int) extends Group("Function") with Arity {
226228
}
227229

228230
def tupleMethod = {
229-
def comment =
231+
def comment =
230232
""" /** Creates a tupled version of this function: instead of %d arguments,
231233
* it accepts a single [[scala.Tuple%d]] argument.
232234
*
@@ -275,7 +277,7 @@ object TupleOne extends Tuple(1)
275277
object TupleTwo extends Tuple(2)
276278
{
277279
override def imports = Tuple.zipImports
278-
override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean, AnyRef) "
280+
override def covariantSpecs = "@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) "
279281
override def moreMethods = """
280282
/** Swaps the elements of this `Tuple`.
281283
* @return a new Tuple where the first element is the second element of this Tuple and the

src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
6969
import definitions.{
7070
BooleanClass, UnitClass, ArrayClass,
7171
ScalaValueClasses, isPrimitiveValueClass, isPrimitiveValueType,
72-
SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, AnyRefModule,
72+
SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass,
7373
GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass
7474
}
7575
import rootMirror.RootClass
@@ -326,7 +326,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
326326
}
327327
}
328328

329-
lazy val specializableTypes = (ScalaValueClasses :+ AnyRefClass) map (_.tpe) sorted
329+
lazy val specializableTypes = ScalaValueClasses map (_.tpe) sorted
330330

331331
/** If the symbol is the companion of a value class, the value class.
332332
* Otherwise, AnyRef.

src/library/scala/Function0.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
** |/ **
77
\* */
88
// GENERATED CODE: DO NOT EDIT.
9-
// genprod generated these sources at: Mon Apr 30 07:46:11 PDT 2012
9+
// genprod generated these sources at: Tue Aug 07 11:54:44 CEST 2012
1010

1111
package scala
1212

@@ -33,7 +33,7 @@ package scala
3333
* latter can specify inputs which it will not handle.
3434
3535
*/
36-
trait Function0[@specialized +R] extends AnyRef { self =>
36+
trait Function0[@specialized(Specializable.Primitives) +R] extends AnyRef { self =>
3737
/** Apply the body of this function to the arguments.
3838
* @return the result of function application.
3939
*/

src/library/scala/Function1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ package scala
3232
3333
*/
3434
@annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.")
35-
trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends AnyRef { self =>
35+
trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) +R] extends AnyRef { self =>
3636
/** Apply the body of this function to the argument.
3737
* @return the result of function application.
3838
*/

src/library/scala/Tuple2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package scala
1616
* @param _1 Element 1 of this Tuple2
1717
* @param _2 Element 2 of this Tuple2
1818
*/
19-
case class Tuple2[@specialized(Int, Long, Double, Char, Boolean, AnyRef) +T1, @specialized(Int, Long, Double, Char, Boolean, AnyRef) +T2](_1: T1, _2: T2)
19+
case class Tuple2[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T1, @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T2](_1: T1, _2: T2)
2020
extends Product2[T1, T2]
2121
{
2222
override def toString() = "(" + _1 + "," + _2 + ")"

src/library/scala/runtime/AbstractFunction0.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
package scala.runtime
1111

12-
abstract class AbstractFunction0[@specialized +R] extends Function0[R] {
12+
abstract class AbstractFunction0[@specialized(Specializable.Primitives) +R] extends Function0[R] {
1313

1414
}

src/library/scala/runtime/AbstractFunction1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
package scala.runtime
1111

12-
abstract class AbstractFunction1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) +R] extends Function1[T1, R] {
12+
abstract class AbstractFunction1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double/*, scala.AnyRef*/) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double/*, scala.AnyRef*/) +R] extends Function1[T1, R] {
1313

1414
}

src/library/scala/specialized.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ import Specializable._
2828

2929
class specialized(group: SpecializedGroup) extends annotation.StaticAnnotation {
3030
def this(types: Specializable*) = this(new Group(types.toList))
31-
def this() = this(Everything)
31+
def this() = this(Primitives)
3232
}

test/files/run/t3575.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// This is here to tell me if the behavior changes, not because
22
// the output is endorsed.
33
case class Two[
4-
@specialized A,
5-
@specialized B
4+
@specialized(Specializable.Everything) A,
5+
@specialized(Specializable.Everything) B
66
](v: A, w: B)
77

88
case class TwoLong[
@@ -16,8 +16,8 @@ case class TwoCool[
1616
](v: A, w: B)
1717

1818
case class TwoShort[
19-
@specialized() A,
20-
@specialized() B
19+
@specialized(Specializable.Everything) A,
20+
@specialized(Specializable.Everything) B
2121
](v: A, w: B)
2222

2323
case class TwoMinimal[
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
474d8c20ab31438d5d4a2ba6bc07ebdcdb530b50 *instrumented.jar
1+
1b11ac773055c1e942c6b5eb4aabdf02292a7194 ?instrumented.jar

0 commit comments

Comments
 (0)