Skip to content

Commit 9442657

Browse files
committed
Fix eta expansion for deeply curried methods
Eta expansion yielded incorrect result if the eta expanded method has more than one parameter sections and the expected result type is a unary function type. In that case a postfix `_' needs to be appended.
1 parent c1aee8f commit 9442657

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

src/dotty/tools/dotc/typer/EtaExpansion.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ object EtaExpansion {
142142
var ids: List[Tree] = mt.paramNames map (name => Ident(name).withPos(tree.pos))
143143
if (mt.paramTypes.nonEmpty && mt.paramTypes.last.isRepeatedParam)
144144
ids = ids.init :+ repeated(ids.last)
145-
val body = Apply(lifted, ids)
145+
var body: Tree = Apply(lifted, ids)
146+
mt.resultType match {
147+
case rt: MethodType if !rt.isImplicit => body = PostfixOp(body, nme.WILDCARD)
148+
case _ =>
149+
}
146150
val fn = untpd.Function(params, body)
147151
if (defs.nonEmpty) untpd.Block(defs.toList map untpd.TypedSplice, fn) else fn
148152
}

tests/pending/run/tcpoly_parseridioms.check

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/pending/run/tcpoly_parseridioms.scala renamed to tests/run/tcpoly_parseridioms.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,5 @@ trait ParserIdioms extends Parsers with Idioms {
108108
}
109109

110110
object Test extends ParserIdioms with App {
111-
println(expr("12".toList))
111+
assert(expr("12".toList).toString == "Success(List(),Plus(1,2))")
112112
}

0 commit comments

Comments
 (0)