Skip to content

Commit c6cbf9e

Browse files
committed
Use dropInlined to correctly drop an inlined node
1 parent 23e4cef commit c6cbf9e

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import dotty.tools.dotc.transform.sjs.JSSymUtils._
3636

3737
import JSEncoding._
3838
import ScopedVar.withScopedVars
39+
import dotty.tools.dotc.inlines.Inlines
3940

4041
/** Main codegen for Scala.js IR.
4142
*
@@ -1930,8 +1931,8 @@ class JSCodeGen()(using genCtx: Context) {
19301931
case EmptyTree =>
19311932
js.Skip()
19321933

1933-
case Inlined(call, bindings, expansion) =>
1934-
genStatOrExpr(Block(bindings, expansion), isStat)
1934+
case inlined @ Inlined(_, _, _) =>
1935+
genStatOrExpr(Inlines.dropInlined(inlined), isStat)
19351936

19361937
case _ =>
19371938
throw new FatalError("Unexpected tree in genExpr: " +

compiler/src/dotty/tools/dotc/inlines/Inlines.scala

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -251,19 +251,11 @@ object Inlines:
251251

252252
/** Replace `Inlined` node by a block that contains its bindings and expansion */
253253
def dropInlined(inlined: Inlined)(using Context): Tree =
254-
val topLevelClass = Option.when(!inlined.call.isEmpty)(inlined.call.symbol.topLevelClass)
255-
val position = (inlined.sourcePos, topLevelClass)
256-
val withPos =
257-
if inlined.expansion.hasAttachment(InliningPosition) then
258-
val att = InliningPosition(position :: inlined.expansion.getAttachment(InliningPosition).get.targetPos)
259-
inlined.expansion.withAttachment(InliningPosition, att)
260-
else
261-
inlined.expansion.withAttachment(InliningPosition, InliningPosition(List(position)))
262254

263255
if inlined.bindings.isEmpty then
264-
withPos
256+
inlined.expansion
265257
else
266-
cpy.Block(inlined)(inlined.bindings, withPos)
258+
cpy.Block(inlined)(inlined.bindings, inlined.expansion)
267259

268260

269261

0 commit comments

Comments
 (0)