aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-07-25 15:50:07 +0200
committerGitHub <noreply@github.com>2016-07-25 15:50:07 +0200
commitb6882d6402bfc290a1fe589425d6dc4ff16976a8 (patch)
tree2a92bb0e6c2b0dd4d8666dbaf8d2f6973e134289
parent11f06fe8435c118a8476b2c197c1973ea4c647aa (diff)
parenta42c4eccdbb623d4f00b406e6985336deb4f3922 (diff)
downloaddotty-b6882d6402bfc290a1fe589425d6dc4ff16976a8.tar.gz
dotty-b6882d6402bfc290a1fe589425d6dc4ff16976a8.tar.bz2
dotty-b6882d6402bfc290a1fe589425d6dc4ff16976a8.zip
Merge pull request #1413 from dotty-staging/fix-#1385
Fix #1385: Temporarily lift 22 limit for functions
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala10
-rw-r--r--src/scala/Function23.scala21
-rw-r--r--src/scala/Function24.scala21
-rw-r--r--tests/pos/i1385.scala7
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..5a19903be 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, 24 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..87a0127cb
--- /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 lambda 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
+ }
+ }
+}