Skip to content

Correct the position of root symbols unpickled from TASTY #4112

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
16 changes: 14 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,24 @@ object Symbols {
* @param coord The coordinates of the symbol (a position or an index)
* @param id A unique identifier of the symbol (unique per ContextBase)
*/
class Symbol private[Symbols] (val coord: Coord, val id: Int) extends Designator with ParamInfo with printing.Showable {
class Symbol private[Symbols] (private[this] var myCoord: Coord, val id: Int) extends Designator with ParamInfo with printing.Showable {

type ThisName <: Name

//assert(id != 723)

def coord: Coord = myCoord
/** Set the coordinate of this class, this is only useful when the coordinate is
* not known at symbol creation. This is the case for root symbols
* unpickled from TASTY.
*
* @pre coord == NoCoord
*/
private[core] def coord_=(c: Coord) = {
assert(myCoord == NoCoord)
myCoord = c
}

/** The last denotation of this symbol */
private[this] var lastDenot: SymDenotation = _
private[this] var checkedPeriod: Period = Nowhere
Expand Down Expand Up @@ -628,7 +640,7 @@ object Symbols {

/** If this is either:
* - a top-level class and `-Yretain-trees` is set
* - a top-level class loaded from TASTY and `-tasty` or `-Xlink` is set
* - a top-level class loaded from TASTY and `-tasty` or `-Xlink` is set
* then return the TypeDef tree (possibly wrapped inside PackageDefs) for this class, otherwise EmptyTree.
* This will force the info of the class.
*/
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -492,10 +492,12 @@ class TreeUnpickler(reader: TastyReader,
val flags = normalizeFlags(tag, givenFlags, name, isAbsType, rhsIsEmpty)
def adjustIfModule(completer: LazyType) =
if (flags is Module) ctx.adjustModuleCompleter(completer, name) else completer
val coord = coordAt(start)
val sym =
roots.find(root => (root.owner eq ctx.owner) && root.name == name) match {
case Some(rootd) =>
pickling.println(i"overwriting ${rootd.symbol} # ${rootd.hashCode}")
rootd.symbol.coord = coord
rootd.info = adjustIfModule(
new Completer(ctx.owner, subReader(start, end)) with SymbolLoaders.SecondCompleter)
rootd.flags = flags &~ Touched // allow one more completion
Expand All @@ -505,8 +507,6 @@ class TreeUnpickler(reader: TastyReader,
case _ =>
val completer = adjustIfModule(new Completer(ctx.owner, subReader(start, end)))

val coord = coordAt(start)

if (isClass)
ctx.newClassSymbol(ctx.owner, name.asTypeName, flags, completer, privateWithin, coord)
else
Expand Down