diff options
Diffstat (limited to 'src/build/genprod.scala')
-rw-r--r-- | src/build/genprod.scala | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala index f85a151ae5..a45dc752cc 100644 --- a/src/build/genprod.scala +++ b/src/build/genprod.scala @@ -1,15 +1,13 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2002-2016, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** \* */ -import scala.language.postfixOps - /** This program generates the ProductN, TupleN, FunctionN, - * and AbstractFunctionN, where 0 <= N <= MAX_ARITY. + * and AbstractFunctionN, where 0 <= N <= MaxArity. * * Usage: scala genprod <directory> * where the argument is the desired output directory @@ -17,8 +15,8 @@ import scala.language.postfixOps * @author Burak Emir, Stephane Micheloud, Geoffrey Washburn, Paul Phillips */ object genprod extends App { - val MAX_ARITY = 22 - def arities = (1 to MAX_ARITY).toList + final val MaxArity = 22 + def arities = (1 to MaxArity).toList class Group(val name: String) { def className(i: Int) = name + i @@ -220,7 +218,7 @@ class Function(val i: Int) extends Group("Function") with Arity { """ /** 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 = { @@ -299,7 +297,7 @@ class Tuple(val i: Int) extends Group("Tuple") with Arity { // prettifies it a little if it's overlong def mkToString() = { def str(xs: List[String]) = xs.mkString(""" + "," + """) - if (i <= MAX_ARITY / 2) str(mdefs) + if (i <= MaxArity / 2) str(mdefs) else { val s1 = str(mdefs take (i / 2)) val s2 = str(mdefs drop (i / 2)) @@ -315,8 +313,7 @@ class Tuple(val i: Int) extends Group("Tuple") with Arity { * @constructor Create a new tuple with {i} elements.{idiomatic} {params} */ -@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0") -case class {className}{covariantArgs}({fields}) +final case class {className}{covariantArgs}({fields}) extends {Product.className(i)}{invariantArgs} {{ override def toString() = "(" + {mkToString} + ")" @@ -364,7 +361,7 @@ class Product(val i: Int) extends Group("Product") with Arity { def cases = { val xs = for ((x, i) <- mdefs.zipWithIndex) yield "case %d => %s".format(i, x) val default = "case _ => throw new IndexOutOfBoundsException(n.toString())" - "\n" + ((xs ::: List(default)) map (" " + _ + "\n") mkString) + "\n" + ((xs ::: List(default)).map(" " + _ + "\n").mkString) } def proj = { (mdefs,targs).zipped.map( (_,_) ).zipWithIndex.map { case ((method,typeName),index) => @@ -373,7 +370,7 @@ class Product(val i: Int) extends Group("Product") with Arity { | */ | def %s: %s |""".stripMargin.format(index + 1, index + 1, method, typeName) - } mkString + }.mkString } def apply() = { @@ -383,7 +380,7 @@ object {className} {{ Some(x) }} -/** {className} is a cartesian product of {i} component{s}. +/** {className} is a Cartesian product of {i} component{s}. * @since 2.3 */ trait {className}{covariantArgs} extends Any with Product {{ |