From b94e6ea5a54d38470e5793c0084785e2d2f9a819 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 30 Nov 2016 14:34:17 +0100 Subject: Drop function 22 limit. Functions with more than 22 parameters are now automatically converted to functions taking a single object array parameter. This has been achieved by tweaking erasure. Other things I have tried that did ot work out well: - Use a single function type in typer. The problem with this one which could not be circumvented was that existing higher-kinded code with e.g. Funcor assumes that Functon1 is a binary type constructor. - Have a late phase that converts to FunctonXXL instead of doing it in erasure. The problem with that one was that potentially every type could be affected, which was ill-suited to the architecture of a miniphase. --- tests/pos/functionXXL.scala | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 tests/pos/functionXXL.scala (limited to 'tests/pos/functionXXL.scala') diff --git a/tests/pos/functionXXL.scala b/tests/pos/functionXXL.scala new file mode 100644 index 000000000..1063e4170 --- /dev/null +++ b/tests/pos/functionXXL.scala @@ -0,0 +1,72 @@ +object Test { + + val f = (x1: Int, + x2: Int, + x3: Int, + x4: Int, + x5: Int, + x6: Int, + x7: Int, + x8: Int, + x9: Int, + x10: Int, + x11: Int, + x12: Int, + x13: Int, + x14: Int, + x15: Int, + x16: Int, + x17: Int, + x18: Int, + x19: Int, + x20: Int, + x21: Int, + x22: Int, + x23: Int, + x24: Int, + x25: Int, + x26: Int) => 42 + + def main(args: Array[String]) = { + val g = (x1: Int, + x2: Int, + x3: Int, + x4: Int, + x5: Int, + x6: Int, + x7: Int, + x8: Int, + x9: Int, + x10: Int, + x11: Int, + x12: Int, + x13: Int, + x14: Int, + x15: Int, + x16: Int, + x17: Int, + x18: Int, + x19: Int, + x20: Int, + x21: Int, + x22: Int, + x23: Int, + x24: Int, + x25: Int, + x26: Int) => f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, + x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, + x21, x22, x23, x24, x25, x26) + + + + println(f(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26)) + + + println(g(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26)) + } + +} -- cgit v1.2.3