diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index d89ba6128274..1f89c8e7337a 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -464,7 +464,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { if (isByName) DefDef(boundSym, arg.changeOwner(ctx.owner, boundSym)) else ValDef(boundSym, arg) }.withSpan(boundSym.span) - bindingsBuf += binding.setDefTree + bindingsBuf += binding binding } @@ -521,7 +521,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { ref(rhsClsSym.sourceModule) else inlineCallPrefix - val binding = ValDef(selfSym.asTerm, QuoteUtils.changeOwnerOfTree(rhs, selfSym)).withSpan(selfSym.span).setDefTree + val binding = ValDef(selfSym.asTerm, QuoteUtils.changeOwnerOfTree(rhs, selfSym)).withSpan(selfSym.span) bindingsBuf += binding inlining.println(i"proxy at $level: $selfSym = ${bindingsBuf.last}") lastSelf = selfSym @@ -797,7 +797,12 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { bindingsBuf.mapInPlace { binding => // Set trees to symbols allow macros to see the definition tree. // This is used by `underlyingArgument`. - reducer.normalizeBinding(binding)(using inlineCtx).setDefTree + val binding1 = reducer.normalizeBinding(binding)(using inlineCtx).setDefTree + binding1.foreachSubTree { + case tree: MemberDef => tree.setDefTree + case _ => + } + binding1 } // Run a typing pass over the inlined tree. See InlineTyper for details. @@ -1382,6 +1387,10 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) { if Inliner.needsInlining(tree) then Inliner.inlineCall(tree) else tree + override def typedUnadapted(tree: untpd.Tree, pt: Type, locked: TypeVars)(using Context): Tree = + super.typedUnadapted(tree, pt, locked) match + case member: MemberDef => member.setDefTree + case tree => tree } /** Drop any side-effect-free bindings that are unused in expansion or other reachable bindings. diff --git a/compiler/src/dotty/tools/dotc/typer/ReTyper.scala b/compiler/src/dotty/tools/dotc/typer/ReTyper.scala index 42c71c1a7b72..8ff0dfc8c61b 100644 --- a/compiler/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/compiler/src/dotty/tools/dotc/typer/ReTyper.scala @@ -115,9 +115,7 @@ class ReTyper extends Typer with ReChecking { } override def typedUnadapted(tree: untpd.Tree, pt: Type, locked: TypeVars)(using Context): Tree = - try super.typedUnadapted(tree, pt, locked) match - case member: MemberDef => member.setDefTree - case tree => tree + try super.typedUnadapted(tree, pt, locked) catch { case NonFatal(ex) => if ctx.phase != Phases.typerPhase && ctx.phase != Phases.inliningPhase then