aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/ast/untpd.scala9
-rw-r--r--src/dotty/tools/dotc/typer/EtaExpansion.scala4
2 files changed, 7 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala
index 28a3cf1ff..85052a4da 100644
--- a/src/dotty/tools/dotc/ast/untpd.scala
+++ b/src/dotty/tools/dotc/ast/untpd.scala
@@ -234,12 +234,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
* parameter, the reference will be a repeated argument.
*/
def refOfDef(tree: MemberDef)(implicit ctx: Context) = tree match {
- case ValDef(_, PostfixOp(_, nme.raw.STAR), _) =>
- Typed(Ident(tree.name), Ident(tpnme.WILDCARD_STAR))
- case _ =>
- Ident(tree.name)
+ case ValDef(_, PostfixOp(_, nme.raw.STAR), _) => repeated(Ident(tree.name))
+ case _ => Ident(tree.name)
}
+ /** A repeated argument such as `arg: _*` */
+ def repeated(arg: Tree)(implicit ctx: Context) = Typed(arg, Ident(tpnme.WILDCARD_STAR))
+
// ------- Decorators -------------------------------------------------
implicit class UntypedTreeDecorator(val self: Tree) extends AnyVal {
diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 89415024e..42fcd94a4 100644
--- a/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -141,8 +141,8 @@ object EtaExpansion {
else mt.paramTypes map TypeTree
val params = (mt.paramNames, paramTypes).zipped.map((name, tpe) =>
ValDef(name, TypeTree(tpe), EmptyTree).withFlags(Synthetic | Param).withPos(tree.pos))
- val ids = mt.paramNames map (name =>
- Ident(name).withPos(tree.pos))
+ var ids: List[Tree] = mt.paramNames map (name => Ident(name).withPos(tree.pos))
+ if (mt.paramTypes.last.isRepeatedParam)ids = ids.init :+ repeated(ids.last)
val body = Apply(lifted, ids)
val fn = untpd.Function(params, body)
if (defs.nonEmpty) untpd.Block(defs.toList map untpd.TypedSplice, fn) else fn