@@ -161,14 +161,14 @@ class InlineReducer(inliner: Inliner)(using Context):
161
161
*/
162
162
def betaReduce (tree : Tree )(using Context ): Tree = tree match {
163
163
case Apply (Select (cl @ closureDef(ddef), nme.apply), args) if defn.isFunctionType(cl.tpe) =>
164
- // closureDef also returns a result for closures wrapped in Inlined nodes.
165
- // These need to be preserved.
164
+ val bindingsBuf = new DefBuffer
166
165
def recur (cl : Tree ): Tree = cl match
166
+ // closureDef also returns a result for closures wrapped in Inlined nodes.
167
+ // These need to be preserved.
167
168
case Inlined (call, bindings, expr) =>
168
169
cpy.Inlined (cl)(call, bindings, recur(expr))
169
170
case _ => ddef.tpe.widen match
170
171
case mt : MethodType if ddef.paramss.head.length == args.length =>
171
- val bindingsBuf = new DefBuffer
172
172
val argSyms = mt.paramNames.lazyZip(mt.paramInfos).lazyZip(args).map { (name, paramtp, arg) =>
173
173
arg.tpe.dealias match {
174
174
case ref @ TermRef (NoPrefix , _) => ref.symbol
@@ -183,9 +183,10 @@ class InlineReducer(inliner: Inliner)(using Context):
183
183
newOwners = ctx.owner :: Nil ,
184
184
substFrom = ddef.paramss.head.map(_.symbol),
185
185
substTo = argSyms)
186
- Block (bindingsBuf.toList, expander.transform(ddef.rhs)).withSpan(tree.span )
186
+ expander.transform(ddef.rhs)
187
187
case _ => tree
188
- recur(cl)
188
+ val reduced = recur(cl)
189
+ Block (bindingsBuf.toList, reduced).withSpan(tree.span)
189
190
case _ => tree
190
191
}
191
192
@@ -281,7 +282,7 @@ class InlineReducer(inliner: Inliner)(using Context):
281
282
// Test case is pos-macros/i15971
282
283
val tptBinds = getBinds(Set .empty[TypeSymbol ], tpt)
283
284
val binds : Set [TypeSymbol ] = pat match {
284
- case UnApply (TypeApply (_, tpts), _, _) =>
285
+ case UnApply (TypeApply (_, tpts), _, _) =>
285
286
getBinds(Set .empty[TypeSymbol ], tpts) ++ tptBinds
286
287
case _ => tptBinds
287
288
}
0 commit comments