summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-03-30 11:42:40 -0700
committerPaul Phillips <paulp@improving.org>2012-03-30 11:43:24 -0700
commit75e584bd0c056a39ea6ef52848e8c2cbe764cb3a (patch)
tree36946236c7d36217e2e6f124260c53eddba171a3
parent0fae7b9064e44b3ee8041a5e5a19e85abfb32e0c (diff)
downloadscala-75e584bd0c056a39ea6ef52848e8c2cbe764cb3a.tar.gz
scala-75e584bd0c056a39ea6ef52848e8c2cbe764cb3a.tar.bz2
scala-75e584bd0c056a39ea6ef52848e8c2cbe764cb3a.zip
Fix for regression with inference at arity 21+.
A classic "off by two" error. Closes SI-4545, SI-5633.
-rw-r--r--src/compiler/scala/reflect/internal/Definitions.scala4
-rw-r--r--test/files/pos/t4545.scala14
2 files changed, 16 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala
index a2dd6fc4c3..09c2228b01 100644
--- a/src/compiler/scala/reflect/internal/Definitions.scala
+++ b/src/compiler/scala/reflect/internal/Definitions.scala
@@ -601,8 +601,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
def isFunctionType(tp: Type): Boolean = tp.normalize match {
case TypeRef(_, sym, args) if args.nonEmpty =>
- val len = args.length
- len < MaxFunctionArity && sym == FunctionClass(len - 1)
+ val arity = args.length - 1 // -1 is the return type
+ arity <= MaxFunctionArity && sym == FunctionClass(arity)
case _ =>
false
}
diff --git a/test/files/pos/t4545.scala b/test/files/pos/t4545.scala
new file mode 100644
index 0000000000..8c7a3236c4
--- /dev/null
+++ b/test/files/pos/t4545.scala
@@ -0,0 +1,14 @@
+object Test {
+ def f[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T](table: Tuple20[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T])(fun: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T) => Unit) {
+ }
+ def g[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U](table: Tuple21[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U])(fun: (A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U) => Unit) {
+ }
+
+ def g20 = f(
+ ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
+ ) { case ((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) => () }
+
+ def g21 = g(
+ (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
+ ) { case ((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)) => () }
+}