Skip to content

Commit cc756c6

Browse files
committed
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.
1 parent bf89558 commit cc756c6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisPh
129129
.appliedToArgss(vparamSymss.map(_.map(ref(_))) :+ clparamSyms.map(ref(_)))
130130
val fwdClosure = cpy.Block(tree)(cpy.DefDef(meth)(rhs = forwarder) :: Nil, cl)
131131
(remappedCore, fwdClosure)
132-
case id: Ident =>
132+
case id: RefTree =>
133133
val SAMType(mt) = id.tpe.widen
134134
splitClosure(tpd.Lambda(mt, args => id.select(nme.apply).appliedToArgs(args))(ctx.withOwner(original)))
135135
case EmptyTree =>

tests/pos/i2723.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
trait App(init: given Array[String] => Unit) {
2+
inline def main(args: Array[String]): Unit = init given args
3+
}

0 commit comments

Comments
 (0)