Skip to content

Commit 75e584b

Browse files
committed
Fix for regression with inference at arity 21+.
A classic "off by two" error. Closes SI-4545, SI-5633.
1 parent 0fae7b9 commit 75e584b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/compiler/scala/reflect/internal/Definitions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,8 +601,8 @@ trait Definitions extends reflect.api.StandardDefinitions {
601601

602602
def isFunctionType(tp: Type): Boolean = tp.normalize match {
603603
case TypeRef(_, sym, args) if args.nonEmpty =>
604-
val len = args.length
605-
len < MaxFunctionArity && sym == FunctionClass(len - 1)
604+
val arity = args.length - 1 // -1 is the return type
605+
arity <= MaxFunctionArity && sym == FunctionClass(arity)
606606
case _ =>
607607
false
608608
}

test/files/pos/t4545.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Test {
2+
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) {
3+
}
4+
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) {
5+
}
6+
7+
def g20 = f(
8+
( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
9+
) { case ((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t)) => () }
10+
11+
def g21 = g(
12+
(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
13+
) { case ((a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u)) => () }
14+
}

0 commit comments

Comments
 (0)