summaryrefslogtreecommitdiff
path: root/src/build/genprod.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-14 22:04:30 -0800
committerPaul Phillips <paulp@improving.org>2012-02-14 23:49:28 -0800
commitbb23d766bceccecc99280b543001bc70e16afbc9 (patch)
treec6c737a25ee99b1910db06f527f0a123d89c6752 /src/build/genprod.scala
parent4c48abbe5a438b5c892ee096d816770213c54ef5 (diff)
downloadscala-bb23d766bceccecc99280b543001bc70e16afbc9.tar.gz
scala-bb23d766bceccecc99280b543001bc70e16afbc9.tar.bz2
scala-bb23d766bceccecc99280b543001bc70e16afbc9.zip
Specialization action.
The crickets at http://www.scala-lang.org/node/11901 were in unanimous agreement that I should proceed as suggested. - No arguments to @specialize gets you 10/10, not 9/10 - Fixed bugs in AnyRef specialization revealed by trying to use it - Specialized Function1 on AnyRef. - Changed AnyRef specialization to use OBJECT_TAG, not TVAR_TAG. - Deprecated SpecializableCompanion in favor of Specializable, which has the virtue of being public so it can be referenced from outside the library. - Cooked up mechanism to group specializable types so we don't have to repeat ourselves quite so much, and create a few groups for illustrative purposes. I'm not too serious about those names but I used up all my name-thinking-up brain for the day. - Updated genprod and friends since I had to regenerate Function1. - Put tests for a bunch of remaining specialization bugs in pending. Closes SI-4740, SI-4770, SI-5267.
Diffstat (limited to 'src/build/genprod.scala')
-rw-r--r--src/build/genprod.scala27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala
index 9e5b6810c1..a43b5e02c7 100644
--- a/src/build/genprod.scala
+++ b/src/build/genprod.scala
@@ -97,7 +97,7 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz */
object FunctionZero extends Function(0) {
override def genprodString = "\n// genprod generated these sources at: " + new java.util.Date()
override def covariantSpecs = "@specialized "
- override def descriptiveComment = functionNTemplate.format("javaVersion", "anonfun0",
+ override def descriptiveComment = " " + functionNTemplate.format("javaVersion", "anonfun0",
"""
* val javaVersion = () => sys.props("java.version")
*
@@ -111,10 +111,10 @@ object FunctionZero extends Function(0) {
object FunctionOne extends Function(1) {
override def classAnnotation = "@annotation.implicitNotFound(msg = \"No implicit view available from ${T1} => ${R}.\")\n"
- override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double) "
- override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) "
+ override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Float, scala.Double, scala.AnyRef) "
+ override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double, scala.AnyRef) "
- override def descriptiveComment = functionNTemplate.format("succ", "anonfun1",
+ override def descriptiveComment = " " + functionNTemplate.format("succ", "anonfun1",
"""
* val succ = (x: Int) => x + 1
* val anonfun1 = new Function1[Int, Int] {
@@ -146,7 +146,7 @@ object FunctionTwo extends Function(2) {
override def contravariantSpecs = "@specialized(scala.Int, scala.Long, scala.Double) "
override def covariantSpecs = "@specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) "
- override def descriptiveComment = functionNTemplate.format("max", "anonfun2",
+ override def descriptiveComment = " " + functionNTemplate.format("max", "anonfun2",
"""
* val max = (x: Int, y: Int) => if (x < y) y else x
*
@@ -175,14 +175,20 @@ class Function(val i: Int) extends Group("Function") with Arity {
*
* {{{
* object Main extends App { %s }
- * }}}"""
+ * }}}
+ *
+ * Note that `Function1` does not define a total function, as might
+ * be suggested by the existence of [[scala.PartialFunction]]. The only
+ * distinction between `Function1` and `PartialFunction` is that the
+ * latter can specify inputs which it will not handle.
+ """
def toStr() = "\"" + ("<function%d>" format i) + "\""
def apply() = {
<file name={fileName}>{header}
/** A function of {i} parameter{s}.
- * {descriptiveComment}
+ *{descriptiveComment}
*/
{classAnnotation}trait {className}{contraCoArgs} extends AnyRef {{ self =>
/** Apply the body of this function to the argument{s}.
@@ -211,12 +217,11 @@ class Function(val i: Int) extends Group("Function") with Arity {
)
// f(x1,x2,x3,x4,x5,x6) == (f.curried)(x1)(x2)(x3)(x4)(x5)(x6)
- def curryComment = { """
- /** Creates a curried version of this function.
+ def curryComment = {
+"""/** Creates a curried version of this function.
*
* @return a function `f` such that `f%s == apply%s`
- */
-""".format(xdefs map ("(" + _ + ")") mkString, commaXs)
+ */""".format(xdefs map ("(" + _ + ")") mkString, commaXs)
}
def tupleMethod = {