Skip to content

Commit 2a9d600

Browse files
committed
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, add ensure that `defTree` is set in the typer. The inliner calls the typer, thus the inlined definitions will have `defTree` set properly.
1 parent e216eea commit 2a9d600

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ object Inliner {
264264
case tree: SeqLiteral => finalize(untpd.SeqLiteral(transform(tree.elems), transform(tree.elemtpt))(curSource))
265265
case tree: Bind => finalize(untpd.Bind(tree.name, transform(tree.body))(curSource))
266266
case tree: TypeTree => finalize(tpd.TypeTree(tree.tpe))
267-
case tree: DefTree => super.transform(tree).setDefTree
267+
case tree: DefTree => super.transform(tree)
268268
case EmptyTree => tree
269269
case _ => fixSpan(super.transform(tree))
270270
}
@@ -463,7 +463,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
463463
if (isByName) DefDef(boundSym, arg.changeOwner(ctx.owner, boundSym))
464464
else ValDef(boundSym, arg)
465465
}.withSpan(boundSym.span)
466-
bindingsBuf += binding.setDefTree
466+
bindingsBuf += binding
467467
binding
468468
}
469469

@@ -520,7 +520,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
520520
ref(rhsClsSym.sourceModule)
521521
else
522522
inlineCallPrefix
523-
val binding = ValDef(selfSym.asTerm, rhs).withSpan(selfSym.span).setDefTree
523+
val binding = ValDef(selfSym.asTerm, rhs).withSpan(selfSym.span)
524524
bindingsBuf += binding
525525
inlining.println(i"proxy at $level: $selfSym = ${bindingsBuf.last}")
526526
lastSelf = selfSym

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2125,7 +2125,7 @@ class Typer extends Namer
21252125
case rhs =>
21262126
typedType(rhs)
21272127
checkFullyAppliedType(rhs1)
2128-
assignType(cpy.TypeDef(tdef)(name, rhs1), sym)
2128+
assignType(cpy.TypeDef(tdef)(name, rhs1), sym).setDefTree
21292129
}
21302130

21312131
def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(using Context): Tree = {
@@ -2265,7 +2265,7 @@ class Typer extends Namer
22652265
for (deriver <- cdef.removeAttachment(AttachedDeriver))
22662266
cdef1.putAttachment(AttachedDeriver, deriver)
22672267

2268-
cdef1
2268+
cdef1.setDefTree
22692269
}
22702270
}
22712271

0 commit comments

Comments
 (0)