Skip to content

Fix owner of symbols created from TASTY LazyReaders #4115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ object PickledQuotes {
val tastyBytes = TastyString.unpickle(expr.tasty)
val unpickled = unpickle(tastyBytes, expr.args)
unpickled match {
case PackageDef(_, (vdef: ValDef) :: Nil) => vdef.rhs
case PackageDef(_, (vdef: ValDef) :: Nil) =>
vdef.rhs.changeOwner(vdef.symbol, ctx.owner)
}
}

Expand All @@ -62,6 +63,7 @@ object PickledQuotes {
unpickled match {
case PackageDef(_, (vdef: ValDef) :: Nil) =>
vdef.rhs.asInstanceOf[TypeApply].args.head
.changeOwner(vdef.symbol, ctx.owner)
}
}

Expand Down
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1122,10 +1122,10 @@ class TreeUnpickler(reader: TastyReader,
setPos(start, CaseDef(pat, guard, rhs))
}

def readLater[T <: AnyRef](end: Addr, op: TreeReader => Context => T): Trees.Lazy[T] = {
def readLater[T <: AnyRef](end: Addr, op: TreeReader => Context => T)(implicit ctx: Context): Trees.Lazy[T] = {
val localReader = fork
goto(end)
new LazyReader(localReader, op)
new LazyReader(localReader, ctx.owner, op)
}

def readHole(end: Addr, isType: Boolean)(implicit ctx: Context): Tree = {
Expand Down Expand Up @@ -1177,10 +1177,10 @@ class TreeUnpickler(reader: TastyReader,
}
}

class LazyReader[T <: AnyRef](reader: TreeReader, op: TreeReader => Context => T) extends Trees.Lazy[T] {
class LazyReader[T <: AnyRef](reader: TreeReader, owner: Symbol, op: TreeReader => Context => T) extends Trees.Lazy[T] {
def complete(implicit ctx: Context): T = {
pickling.println(i"starting to read at ${reader.reader.currentAddr}")
op(reader)(ctx.withPhaseNoLater(ctx.picklerPhase))
pickling.println(i"starting to read at ${reader.reader.currentAddr} with owner $owner")
op(reader)(ctx.withPhaseNoLater(ctx.picklerPhase).withOwner(owner))
}
}

Expand Down
3 changes: 0 additions & 3 deletions compiler/test/dotty/tools/dotc/FromTastyTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ class FromTastyTests extends ParallelTesting {
"spec-sparsearray-old.scala",
"collections_1.scala",

// Anonymous method not defined
"i3067.scala",

// Infinite compilation
"t3612.scala",
)
Expand Down