@@ -1254,14 +1254,8 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
1254
1254
super .ensureAccessible(tpe, superAccess, pos)
1255
1255
}
1256
1256
1257
- override def typed (tree : untpd.Tree , pt : Type = WildcardType )(using Context ): Tree =
1258
- val tree1 = super .typed(tree, pt)
1259
- if Inliner .needsInlining(tree1)
1260
- then Inliner .inlineCall(tree1)
1261
- else tree1
1262
-
1263
1257
override def typedIdent (tree : untpd.Ident , pt : Type )(using Context ): Tree =
1264
- tryInlineArg(tree.asInstanceOf [tpd.Tree ]) `orElse` super .typedIdent(tree, pt)
1258
+ inlineIfNeeded( tryInlineArg(tree.asInstanceOf [tpd.Tree ]) `orElse` super .typedIdent(tree, pt) )
1265
1259
1266
1260
override def typedSelect (tree : untpd.Select , pt : Type )(using Context ): Tree = {
1267
1261
assert(tree.hasType, tree)
@@ -1273,7 +1267,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
1273
1267
else
1274
1268
val res = resMaybeReduced
1275
1269
ensureAccessible(res.tpe, tree.qualifier.isInstanceOf [untpd.Super ], tree.srcPos)
1276
- res
1270
+ inlineIfNeeded( res)
1277
1271
}
1278
1272
1279
1273
override def typedIf (tree : untpd.If , pt : Type )(using Context ): Tree =
@@ -1310,14 +1304,14 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
1310
1304
val expanded = expandMacro(res.args.head, tree.span)
1311
1305
typedExpr(expanded) // Inline calls and constant fold code generated by the macro
1312
1306
case res =>
1313
- res
1307
+ inlineIfNeeded( res)
1314
1308
}
1315
1309
if res.symbol == defn.QuotedRuntime_exprQuote then
1316
1310
ctx.compilationUnit.needsQuotePickling = true
1317
1311
res
1318
1312
1319
1313
override def typedTypeApply (tree : untpd.TypeApply , pt : Type )(using Context ): Tree =
1320
- constToLiteral(betaReduce(super .typedTypeApply(tree, pt)))
1314
+ inlineIfNeeded( constToLiteral(betaReduce(super .typedTypeApply(tree, pt) )))
1321
1315
1322
1316
override def typedMatch (tree : untpd.Match , pt : Type )(using Context ): Tree =
1323
1317
val tree1 =
@@ -1376,6 +1370,10 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
1376
1370
/** True if this inline typer has already issued errors */
1377
1371
override def hasInliningErrors (using Context ) = ctx.reporter.errorCount > initialErrorCount
1378
1372
1373
+ private def inlineIfNeeded (tree : Tree )(using Context ): Tree =
1374
+ if Inliner .needsInlining(tree) then Inliner .inlineCall(tree)
1375
+ else tree
1376
+
1379
1377
}
1380
1378
1381
1379
/** Drop any side-effect-free bindings that are unused in expansion or other reachable bindings.
0 commit comments