Skip to content

Commit df1ba15

Browse files
committed
Force inline scrutinees of inline matches
1 parent e33c632 commit df1ba15

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,15 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
13001300
override def typedTypeApply(tree: untpd.TypeApply, pt: Type)(using Context): Tree =
13011301
inlineIfIsNestedInlineCall(constToLiteral(betaReduce(super.typedTypeApply(tree, pt))))
13021302

1303+
override def typedMatch(tree: untpd.Match, pt: Type)(using Context): Tree =
1304+
val tree1 =
1305+
if tree.isInline then
1306+
// TODO this might not be useful if we do not support #11291
1307+
val sel1 = typedExpr(tree.selector)(using ctx.addMode(Mode.ForceInline))
1308+
untpd.cpy.Match(tree)(sel1, tree.cases)
1309+
else tree
1310+
super.typedMatch(tree1, pt)
1311+
13031312
override def typedMatchFinish(tree: untpd.Match, sel: Tree, wideSelType: Type, cases: List[untpd.CaseDef], pt: Type)(using Context) =
13041313
if (!tree.isInline || ctx.owner.isInlineMethod) // don't reduce match of nested inline method yet
13051314
super.typedMatchFinish(tree, sel, wideSelType, cases, pt)

0 commit comments

Comments
 (0)