Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,16 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
}
}

/** Strip `Typed` nodes, recursing into `Block` nodes. */
def stripSyntheticTyped(tree: Tree)(using Context): Tree =
unsplice(tree) match
case Typed(expr, _) if tree.span.isSynthetic =>
stripSyntheticTyped(expr)
case Block(stats, expr) =>
cpy.Block(tree)(stats, stripSyntheticTyped(expr))
case _ =>
tree

/** The type and term arguments of a possibly curried call, in the order they are given */
def allArgss(tree: Tree): List[List[Tree]] =
@tailrec
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/inlines/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ class Inliner(val call: tpd.Tree)(using Context):
}

// Run a typing pass over the inlined tree. See InlineTyper for details.
val expansion1 = inlineTyper.typed(expansion)(using inlineCtx)
val expansion1 = inlineTyper.typed(stripSyntheticTyped(expansion))(using inlineCtx)

if (ctx.settings.verbose.value) {
inlining.println(i"to inline = $rhsToInline")
Expand Down
1 change: 1 addition & 0 deletions tests/run/i24420-inline-local-ref.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
12 changes: 12 additions & 0 deletions tests/run/i24420-inline-local-ref.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
inline def f(): Long =
1L

inline def g(): Long =
inline val x = f()
x

inline def h(): Long =
inline if g() > 0L then 1L else 0L

@main def Test: Unit =
println(h())
1 change: 1 addition & 0 deletions tests/run/i24420-transparent-inline-local-ref.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
12 changes: 12 additions & 0 deletions tests/run/i24420-transparent-inline-local-ref.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
transparent inline def f(): Long =
1L

transparent inline def g(): Long =
inline val x = f()
x

transparent inline def h(): Long =
inline if g() > 0L then 1L else 0L

@main def Test: Unit =
println(h())
Loading