Skip to content

Commit 5d54e68

Browse files
committed
Only strip synthetic ascriptions inside inlined defs
1 parent 96b1b83 commit 5d54e68

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,8 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
836836
unsplice(tree) match
837837
case Typed(expr, _) if tree.span.isSynthetic =>
838838
stripSyntheticTyped(expr)
839+
case tree @ Inlined(call, bindings, expr) =>
840+
cpy.Inlined(tree)(call, bindings, stripSyntheticTyped(expr))
839841
case Block(stats, expr) =>
840842
cpy.Block(tree)(stats, stripSyntheticTyped(expr))
841843
case _ =>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ class Inliner(val call: tpd.Tree)(using Context):
790790
}
791791

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

795795
if (ctx.settings.verbose.value) {
796796
inlining.println(i"to inline = $rhsToInline")
@@ -1056,7 +1056,8 @@ class Inliner(val call: tpd.Tree)(using Context):
10561056
val meth = tree.symbol
10571057
if meth.isAllOf(DeferredInline) then
10581058
errorTree(tree, em"Deferred inline ${meth.showLocated} cannot be invoked")
1059-
else if Inlines.needsInlining(tree) then Inlines.inlineCall(simplify(tree, pt, locked))
1059+
else if Inlines.needsInlining(tree) then
1060+
stripSyntheticTyped(Inlines.inlineCall(simplify(tree, pt, locked)))
10601061
else tree
10611062

10621063
override def typedUnadapted(tree: untpd.Tree, pt: Type, locked: TypeVars)(using Context): Tree =

tests/run/i24420-inline-local-ref.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/run/i24420-inline-local-ref.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ inline def h(): Long =
99
inline if g() > 0L then 1L else 0L
1010

1111
@main def Test: Unit =
12-
println(h())
12+
assert(h() == 1L)

tests/run/i24420-transparent-inline-local-ref.check

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/run/i24420-transparent-inline-local-ref.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ transparent inline def h(): Long =
99
inline if g() > 0L then 1L else 0L
1010

1111
@main def Test: Unit =
12-
println(h())
12+
assert(h() == 1L)

0 commit comments

Comments
 (0)