summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-02-10 18:45:55 +0000
committerPaul Phillips <paulp@improving.org>2009-02-10 18:45:55 +0000
commitf4720669d6b4946653b5b419d85f5ec5a1e95bad (patch)
treedb26965e258472e2ff56aa216b8fcc36d37a9ab6
parent8d017c0f1e3478f2736a8df624492b73190b0976 (diff)
downloadscala-f4720669d6b4946653b5b419d85f5ec5a1e95bad.tar.gz
scala-f4720669d6b4946653b5b419d85f5ec5a1e95bad.tar.bz2
scala-f4720669d6b4946653b5b419d85f5ec5a1e95bad.zip
Fixes and test cases for #944 and #1523.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala3
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala3
-rw-r--r--test/files/neg/bug1523.check4
-rw-r--r--test/files/neg/bug1523.scala5
-rw-r--r--test/files/neg/bug944.check4
-rw-r--r--test/files/neg/bug944.scala6
6 files changed, 24 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 7009adb35d..81bbfd1396 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -59,7 +59,8 @@ trait Infer {
else actuals
def actualArgs(pos: Position, actuals: List[Tree], nformals: Int): List[Tree] =
- if (nformals == 1 && actuals.length != 1 && !phase.erasedTypes) List(atPos(pos)(gen.mkTuple(actuals))) else actuals
+ if (nformals == 1 && actuals.length != 1 && actuals.length <= definitions.MaxTupleArity && !phase.erasedTypes)
+ List(atPos(pos)(gen.mkTuple(actuals))) else actuals
/** A fresh type varable with given type parameter as origin.
*
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index ecce748314..20e5a9101e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1516,6 +1516,9 @@ trait Typers { self: Analyzer =>
def typedFunction(fun: Function, mode: Int, pt: Type): Tree = {
val codeExpected = !forCLDC && !forMSIL && (pt.typeSymbol isNonBottomSubClass CodeClass)
+ if (fun.vparams.length > definitions.MaxFunctionArity)
+ return errorTree(fun, "implementation restricts functions to " + definitions.MaxFunctionArity + " parameters")
+
def decompose(pt: Type): (Symbol, List[Type], Type) =
if ((isFunctionType(pt)
||
diff --git a/test/files/neg/bug1523.check b/test/files/neg/bug1523.check
new file mode 100644
index 0000000000..a28ffcb902
--- /dev/null
+++ b/test/files/neg/bug1523.check
@@ -0,0 +1,4 @@
+bug1523.scala:4: error: wrong number of arguments for method bug: (Any)Any
+ def go() = bug("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a")
+ ^
+one error found
diff --git a/test/files/neg/bug1523.scala b/test/files/neg/bug1523.scala
new file mode 100644
index 0000000000..cd287759d9
--- /dev/null
+++ b/test/files/neg/bug1523.scala
@@ -0,0 +1,5 @@
+object test {
+ def bug(x: Any) = x
+
+ def go() = bug("a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a")
+} \ No newline at end of file
diff --git a/test/files/neg/bug944.check b/test/files/neg/bug944.check
new file mode 100644
index 0000000000..d45b968e9e
--- /dev/null
+++ b/test/files/neg/bug944.check
@@ -0,0 +1,4 @@
+bug944.scala:5: error: implementation restricts functions to 22 parameters
+ a23:Int) => 1
+ ^
+one error found
diff --git a/test/files/neg/bug944.scala b/test/files/neg/bug944.scala
new file mode 100644
index 0000000000..154e91c8ee
--- /dev/null
+++ b/test/files/neg/bug944.scala
@@ -0,0 +1,6 @@
+object TooManyArgsFunction {
+ val f = (a1:Int, a2:Int, a3:Int, a4:Int, a5:Int, a6:Int, a7:Int, a8:Int,
+ a9:Int, a10:Int, a11:Int, a12:Int, a13:Int, a14:Int, a15:Int,
+ a16:Int, a17:Int, a18:Int, a19:Int, a20:Int, a21:Int, a22:Int,
+ a23:Int) => 1
+} \ No newline at end of file