From a98d42abbe8408d04910df3f00840b682d83d4f4 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Fri, 12 Feb 2021 11:15:04 +0100 Subject: [PATCH] Set defTree properly In the following test: - tests/pos/i3130b.scala If we add `transparent`, then everything is OK. The reason is that we set `Symbol.defTree` systematically in PostTyper. Now the inlining happens after PostTyper, thus `defTree` is not properly set for inlined definitions. To compensate, we ensure that `defTree` is set in the ReTyper. The IninerTyper extends ReTyper, thus it fixes the problem. Doing the fix directly in InlinerTyper, however, does not pass the CI. The reason is that `-Ycheck:all` will run `TreeChecker` which will make tree bindings get lost. --- compiler/src/dotty/tools/dotc/typer/ReTyper.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/ReTyper.scala b/compiler/src/dotty/tools/dotc/typer/ReTyper.scala index 8ff0dfc8c61b..42c71c1a7b72 100644 --- a/compiler/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/compiler/src/dotty/tools/dotc/typer/ReTyper.scala @@ -115,7 +115,9 @@ 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) + try super.typedUnadapted(tree, pt, locked) match + case member: MemberDef => member.setDefTree + case tree => tree catch { case NonFatal(ex) => if ctx.phase != Phases.typerPhase && ctx.phase != Phases.inliningPhase then