From ded374a5229a17c5c6dc04e50044d62422dc1023 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 19 Dec 2015 22:31:00 +0100 Subject: [PATCH] Fix eta expansion revios fix crashed for nullary functions --- src/dotty/tools/dotc/typer/EtaExpansion.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala index 42fcd94a46a9..aa210e6ed40a 100644 --- a/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -142,7 +142,8 @@ object EtaExpansion { val params = (mt.paramNames, paramTypes).zipped.map((name, tpe) => ValDef(name, TypeTree(tpe), EmptyTree).withFlags(Synthetic | Param).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) + if (mt.paramTypes.nonEmpty && 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