diff options
author | Martin Odersky <odersky@gmail.com> | 2016-07-25 10:35:59 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-25 10:36:07 +0200 |
commit | 226c7cb390d53acc2c18918d5a8f4b7133d4a4ac (patch) | |
tree | 9b2c729a0afb051adb95a1237a4291d075747778 | |
parent | 11f06fe8435c118a8476b2c197c1973ea4c647aa (diff) | |
download | dotty-226c7cb390d53acc2c18918d5a8f4b7133d4a4ac.tar.gz dotty-226c7cb390d53acc2c18918d5a8f4b7133d4a4ac.tar.bz2 dotty-226c7cb390d53acc2c18918d5a8f4b7133d4a4ac.zip |
Fix #1385: Temporarily lift 22 limit for functions
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 10 | ||||
-rw-r--r-- | src/scala/Function23.scala | 21 | ||||
-rw-r--r-- | src/scala/Function24.scala | 21 | ||||
-rw-r--r-- | tests/pos/i1385.scala | 7 |
4 files changed, 57 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index 6d183fe40..34b2d0562 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -12,7 +12,13 @@ import collection.mutable import scala.reflect.api.{ Universe => ApiUniverse } object Definitions { - val MaxFunctionArity, MaxTupleArity = 22 + val MaxTupleArity, MaxAbstractFunctionArity = 22 + val MaxFunctionArity = 24 + // Awaiting a definite solution that drops the limit altogether, 44 gives a safety + // margin over the previous 22, so that treecopiers in miniphases are allowed to + // temporarily create larger closures. This is needed in lambda lift where large closures + // are first formed by treecopiers before they are split apart into parameters and + // environment in the lambdalift transform itself. } /** A class defining symbols and types of standard definitions @@ -587,7 +593,7 @@ class Definitions { // ----- Symbol sets --------------------------------------------------- - lazy val AbstractFunctionType = mkArityArray("scala.runtime.AbstractFunction", MaxFunctionArity, 0) + lazy val AbstractFunctionType = mkArityArray("scala.runtime.AbstractFunction", MaxAbstractFunctionArity, 0) val AbstractFunctionClassPerRun = new PerRun[Array[Symbol]](implicit ctx => AbstractFunctionType.map(_.symbol.asClass)) def AbstractFunctionClass(n: Int)(implicit ctx: Context) = AbstractFunctionClassPerRun()(ctx)(n) lazy val FunctionType = mkArityArray("scala.Function", MaxFunctionArity, 0) diff --git a/src/scala/Function23.scala b/src/scala/Function23.scala new file mode 100644 index 000000000..254772d53 --- /dev/null +++ b/src/scala/Function23.scala @@ -0,0 +1,21 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala + + +/** A function of 23 parameters. Used as a temporary fix until arity limit is dropped. + * + */ +trait Function23[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, -T23, +R] extends AnyRef { self => + /** Apply the body of this function to the arguments. + * @return the result of function application. + */ + def apply(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9, v10: T10, v11: T11, v12: T12, v13: T13, v14: T14, v15: T15, v16: T16, v17: T17, v18: T18, v19: T19, v20: T20, v21: T21, v22: T22, v23: T23): R + + override def toString() = "<function23>" +} diff --git a/src/scala/Function24.scala b/src/scala/Function24.scala new file mode 100644 index 000000000..8af8ed995 --- /dev/null +++ b/src/scala/Function24.scala @@ -0,0 +1,21 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ +package scala + + +/** A function of 24 parameters. Used as a temporary fix until arity limit is dropped. + * + */ +trait Function24[-T1, -T2, -T3, -T4, -T5, -T6, -T7, -T8, -T9, -T10, -T11, -T12, -T13, -T14, -T15, -T16, -T17, -T18, -T19, -T20, -T21, -T22, -T23, -T24, +R] extends AnyRef { self => + /** Apply the body of this function to the arguments. + * @return the result of function application. + */ + def apply(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5, v6: T6, v7: T7, v8: T8, v9: T9, v10: T10, v11: T11, v12: T12, v13: T13, v14: T14, v15: T15, v16: T16, v17: T17, v18: T18, v19: T19, v20: T20, v21: T21, v22: T22, v23: T23, v24: T24): R + + override def toString() = "<function24>" +} diff --git a/tests/pos/i1385.scala b/tests/pos/i1385.scala new file mode 100644 index 000000000..d9fc015ce --- /dev/null +++ b/tests/pos/i1385.scala @@ -0,0 +1,7 @@ +object Test { +def foo22[T](c1:T, c2:T, c3:T, c4:T, c5:T, c6:T, c7:T, c8:T, c9:T, c10:T, c11:T, c12:T, c13:T, c14:T, c15:T, c16:T, c17:T, c18:T, c19:T, c20:T, c21:T, c22:T): Int => T = { + (a: Int) => { // This labda ends with 23 parameters (c1 to c22 and a) + c22; c21; c20; c19; c18; c17; c16; c15; c14; c13; c12; c11; c10; c9; c8; c7; c6; c5; c4; c3; c2; c1 + } + } +} |