Skip to content

Commit 1b4ca37

Browse files
committed
Remember owner in completer
Otherwise we might get a false owner if completing from somewhere else. We do not have a failing test to demonstrate the problem, but it looks like the right thing to do.
1 parent bef7363 commit 1b4ca37

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
9292
def toTermName(ref: NameRef): TermName = toTermName(tastyName(ref))
9393
def toTypeName(ref: NameRef): TypeName = toTermName(ref).toTypeName
9494

95-
class Completer(reader: TastyReader) extends LazyType {
95+
class Completer(owner: Symbol, reader: TastyReader) extends LazyType {
9696
import reader._
9797
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
9898
treeAtAddr(currentAddr) =
9999
new TreeReader(reader).readIndexedDef()(
100-
ctx.withPhaseNoLater(ctx.picklerPhase))//(ctx.withOwner(owner))
100+
ctx.withPhaseNoLater(ctx.picklerPhase).withOwner(owner))
101101
}
102102
}
103103

@@ -463,12 +463,12 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
463463
case Some(rootd) =>
464464
pickling.println(i"overwriting ${rootd.symbol} # ${rootd.hashCode}")
465465
rootd.info = adjustIfModule(
466-
new Completer(subReader(start, end)) with SymbolLoaders.SecondCompleter)
466+
new Completer(ctx.owner, subReader(start, end)) with SymbolLoaders.SecondCompleter)
467467
rootd.flags = flags &~ Touched // allow one more completion
468468
rootd.privateWithin = privateWithin
469469
rootd.symbol
470470
case _ =>
471-
val completer = adjustIfModule(new Completer(subReader(start, end)))
471+
val completer = adjustIfModule(new Completer(ctx.owner, subReader(start, end)))
472472
if (isClass)
473473
ctx.newClassSymbol(ctx.owner, name.asTypeName, flags, completer, privateWithin, coord = start.index)
474474
else

0 commit comments

Comments
 (0)