diff options
Diffstat (limited to 'sources/scalac/transformer')
-rw-r--r-- | sources/scalac/transformer/UnCurry.java | 28 | ||||
-rw-r--r-- | sources/scalac/transformer/matching/AlgebraicMatcher.java | 4 |
2 files changed, 22 insertions, 10 deletions
diff --git a/sources/scalac/transformer/UnCurry.java b/sources/scalac/transformer/UnCurry.java index 2293e5e8f2..1f17e47a49 100644 --- a/sources/scalac/transformer/UnCurry.java +++ b/sources/scalac/transformer/UnCurry.java @@ -213,7 +213,8 @@ public class UnCurry extends OwnerTransformer switch (methtype) { case MethodType(Symbol[] params, _): - if (params.length == 1 && (params[0].flags & REPEATED) != 0) { + if (params.length > 0 && + (params[params.length-1].flags & REPEATED) != 0) { args = toSequence(pos, params, args); } Tree[] args1 = args; @@ -240,16 +241,27 @@ public class UnCurry extends OwnerTransformer * escaping */ private Tree[] toSequence(int pos, Symbol[] params, Tree[] args) { - assert (args.length != 1 - || !(args[0] instanceof Tree.Sequence) - || TreeInfo.isSequenceValued( args[0])); - if (args.length == 1) { - switch (args[0]) { + Tree[] result = new Tree[params.length]; + for (int i = 0; i < params.length - 1; i++) + result[i] = args[i]; + assert (args.length != params.length + || !(args[params.length-1] instanceof Tree.Sequence) + || TreeInfo.isSequenceValued(args[params.length-1])); + if (args.length == params.length) { + switch (args[params.length-1]) { case Typed(Tree arg, Ident(TypeNames.WILDCARD_STAR)): - return new Tree[]{arg}; + result[params.length-1] = arg; + return result; } } - return new Tree[]{make.Sequence( pos, args ).setType(params[0].type())}; + Tree[] args1 = args; + if (params.length != 1) { + args1 = new Tree[args.length - (params.length - 1)]; + System.arraycopy(args, params.length - 1, args1, 0, args1.length); + } + result[params.length-1] = + make.Sequence(pos, args1).setType(params[params.length-1].type()); + return result; } /** for every argument to a def parameter `def x: T': diff --git a/sources/scalac/transformer/matching/AlgebraicMatcher.java b/sources/scalac/transformer/matching/AlgebraicMatcher.java index 4708dd6258..7c564882b3 100644 --- a/sources/scalac/transformer/matching/AlgebraicMatcher.java +++ b/sources/scalac/transformer/matching/AlgebraicMatcher.java @@ -110,8 +110,8 @@ public class AlgebraicMatcher extends PatternMatcher { //System.err.println( tree.fun.type.resultType().symbol() ); return (tree.args.length == 1) && (tree.type.symbol().flags & Modifiers.CASE) != 0 - && params.length == 1 - && (params[ 0 ].flags & Modifiers.REPEATED) != 0; + && params.length > 0 + && (params[params.length-1].flags & Modifiers.REPEATED) != 0; } //////////// generator methods |