Skip to content

Commit

Permalink
Set defTree properly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
liufengyun committed Feb 16, 2021
1 parent 632a424 commit a98d42a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/ReTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a98d42a

Please sign in to comment.