From cc756c65a9c6db84cb9bc633e888c0e8758316dc Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Mon, 3 Jun 2019 14:30:19 +0200 Subject: [PATCH] Fix #2723: generate direct method for inline accessors If the inline accessor is an implicit function type, the rhs is a RefTree instead of a closure. We need to first eta-expand and then generate the direct method. --- .../src/dotty/tools/dotc/transform/ShortcutImplicits.scala | 2 +- tests/pos/i2723.scala | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i2723.scala diff --git a/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala b/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala index 06c265e29d2a..39ef97865da7 100644 --- a/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala +++ b/compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala @@ -129,7 +129,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisPh .appliedToArgss(vparamSymss.map(_.map(ref(_))) :+ clparamSyms.map(ref(_))) val fwdClosure = cpy.Block(tree)(cpy.DefDef(meth)(rhs = forwarder) :: Nil, cl) (remappedCore, fwdClosure) - case id: Ident => + case id: RefTree => val SAMType(mt) = id.tpe.widen splitClosure(tpd.Lambda(mt, args => id.select(nme.apply).appliedToArgs(args))(ctx.withOwner(original))) case EmptyTree => diff --git a/tests/pos/i2723.scala b/tests/pos/i2723.scala new file mode 100644 index 000000000000..3391b11dcb50 --- /dev/null +++ b/tests/pos/i2723.scala @@ -0,0 +1,3 @@ +trait App(init: given Array[String] => Unit) { + inline def main(args: Array[String]): Unit = init given args +}