@@ -220,7 +220,7 @@ abstract class UnCurry extends InfoTransform
220
220
// Normally, we can unwrap `() => cbn` to `cbn` where `cbn` refers to a CBN argument (typically `cbn` is an Ident),
221
221
// because we know `cbn` will already be a `Function0` thunk. When we're targeting a SAM,
222
222
// the types don't align and we must preserve the function wrapper.
223
- if (fun.vparams.isEmpty && isByNameRef(fun.body) && fun.attachments.get [SAMFunction ].isEmpty ) {
223
+ if (fun.vparams.isEmpty && isByNameRef(fun.body) && ! fun.attachments.contains [SAMFunction ]) {
224
224
noApply += fun.body
225
225
fun.body
226
226
}
@@ -236,27 +236,26 @@ abstract class UnCurry extends InfoTransform
236
236
val newFun = deriveFunction(fun)(_ => localTyper.typedPos(fun.pos)(
237
237
gen.mkForwarder(gen.mkAttributedRef(liftedMethod.symbol), (fun.vparams map (_.symbol)) :: Nil )
238
238
))
239
+ def typeNewFun = localTyper.typedPos(fun.pos)(Block (liftedMethod :: Nil , super .transform(newFun)))
239
240
240
241
if (! mustExpand) {
241
242
liftedMethod.symbol.updateAttachment(DelambdafyTarget )
242
243
liftedMethod.updateAttachment(DelambdafyTarget )
244
+ typeNewFun
243
245
}
244
-
245
- val typedNewFun = localTyper.typedPos(fun.pos)(Block (liftedMethod :: Nil , super .transform(newFun)))
246
- if (mustExpand) {
247
- val Block (stats, expr : Function ) = typedNewFun : @ unchecked
248
- val expansion = gen.expandFunction(localTyper)(expr, inConstructorFlag)
249
- expansion match {
250
- case Block (ClassDef (_, _, _, Template (_, _, body)) :: Nil , _) =>
251
- body.last match {
252
- case DefDef (_, _, _, _, _, Apply (_, args)) => noApply.addAll(args) // samDef args are pass-thru
253
- case _ =>
254
- }
255
- case _ =>
256
- }
257
- treeCopy.Block (typedNewFun, stats, expansion)
258
- } else {
259
- typedNewFun
246
+ else typeNewFun match {
247
+ case typedNewFun @ Block (stats, expr : Function ) =>
248
+ val expansion = gen.expandFunction(localTyper)(expr, inConstructorFlag)
249
+ expansion match {
250
+ case Block (ClassDef (_, _, _, Template (_, _, body)) :: Nil , _) =>
251
+ body.last match {
252
+ case DefDef (_, _, _, _, _, Apply (_, args)) => noApply.addAll(args) // samDef args are pass-thru
253
+ case _ =>
254
+ }
255
+ case _ =>
256
+ }
257
+ treeCopy.Block (typedNewFun, stats, expansion)
258
+ case x => throw new MatchError (x)
260
259
}
261
260
}
262
261
0 commit comments