diff options
author | Seth Tisue <seth@tisue.net> | 2016-08-29 00:43:58 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-29 09:43:58 +0200 |
commit | 3304bc33987f5821912bb0c7371b5e9a115c893d (patch) | |
tree | 124e048b8dcbadae0d7d9dbd4144c9960e4de2e9 /src | |
parent | 90bced5b659e174b01a44999ef7ce4b810c73c4a (diff) | |
download | scala-3304bc33987f5821912bb0c7371b5e9a115c893d.tar.gz scala-3304bc33987f5821912bb0c7371b5e9a115c893d.tar.bz2 scala-3304bc33987f5821912bb0c7371b5e9a115c893d.zip |
clean up genprod, get rid of warning (#5361)
No more "Selecting value MAX_ARITY from object genprod,
which extends scala.DelayedInit, is likely to yield an
uninitialized value" at start of every build.
Diffstat (limited to 'src')
-rw-r--r-- | src/build/genprod.scala | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala index fa48b020cc..74adb6237e 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)) @@ -363,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) => @@ -372,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() = { |