From 46d607624e2b10663634e3cfed7dc0e1f8a50a19 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 4 Feb 2021 13:04:17 +0100 Subject: [PATCH 1/2] Don't use suffix `_` in eta expansion There was a superfluous `_` added in eta expansion. That was needed in Scala 2, but is no longer needed in Scala 3. Fixes #11311 --- compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala | 5 ++--- tests/pos/i11311.scala | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 tests/pos/i11311.scala diff --git a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala index c4936b5a3a9e..2fe62cbf0ffa 100644 --- a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -241,9 +241,8 @@ object EtaExpansion extends LiftImpure { var ids: List[Tree] = mt.paramNames map (name => Ident(name).withSpan(tree.span.startPos)) if (mt.paramInfos.nonEmpty && mt.paramInfos.last.isRepeatedParam) ids = ids.init :+ repeated(ids.last) - val app = Apply(lifted, ids) - if (mt.isContextualMethod) app.setApplyKind(ApplyKind.Using) - val body = if (isLastApplication) app else PostfixOp(app, Ident(nme.WILDCARD)) + val body = Apply(lifted, ids) + if (mt.isContextualMethod) body.setApplyKind(ApplyKind.Using) val fn = if (mt.isContextualMethod) new untpd.FunctionWithMods(params, body, Modifiers(Given)) else if (mt.isImplicitMethod) new untpd.FunctionWithMods(params, body, Modifiers(Implicit)) diff --git a/tests/pos/i11311.scala b/tests/pos/i11311.scala new file mode 100644 index 000000000000..c57e0a109099 --- /dev/null +++ b/tests/pos/i11311.scala @@ -0,0 +1,4 @@ +object Test: + + def cat1(s1: String)(s2: String) = s1 + s2 + val fcat1 = cat1 From a8b80877616eb58878133698e2fe1df223f39060 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 5 Feb 2021 10:16:13 +0100 Subject: [PATCH 2/2] Fix source version for test --- tests/pos/i11311.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pos/i11311.scala b/tests/pos/i11311.scala index c57e0a109099..6ab995ad6411 100644 --- a/tests/pos/i11311.scala +++ b/tests/pos/i11311.scala @@ -1,3 +1,4 @@ +import language.`3.1` object Test: def cat1(s1: String)(s2: String) = s1 + s2