Skip to content

ReadPositions when unpickling a coord of a symbol #8987

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

Closed
Closed
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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ class TreeUnpickler(reader: TastyReader,
def complete(denot: SymDenotation)(implicit ctx: Context) =
denot.info = typeReader.readType()
}
val sym = ctx.newSymbol(ctx.owner, name, Flags.Case, completer, coord = coordAt(start))
val sym = ctx.newSymbol(ctx.owner, name, Flags.Case, completer, coord = coordAt(start)(ctx.addMode(Mode.ReadPositions)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addMode is somewhat expensive since it will require making a copy of the Context if the mode isn't already present. Maybe coordAt should have an extra parameter to force reading the position even if ReadPosition isn't set. I think we should discuss the purpose of ReadPosition in the next meeting because I don't recall the details.

registerSym(start, sym)
sym
}
Expand Down Expand Up @@ -559,7 +559,7 @@ 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 coord = coordAt(start)(ctx.addMode(Mode.ReadPositions))
val sym =
roots.find(root => (root.owner eq ctx.owner) && root.name == name) match {
case Some(rootd) =>
Expand Down Expand Up @@ -1188,7 +1188,7 @@ class TreeUnpickler(reader: TastyReader,
UnApply(fn, implicitArgs, argPats, patType)
case REFINEDtpt =>
val refineCls = symAtAddr.getOrElse(start,
ctx.newRefinedClassSymbol(coordAt(start))).asClass
ctx.newRefinedClassSymbol(coordAt(start)(ctx.addMode(Mode.ReadPositions)))).asClass
registerSym(start, refineCls)
typeAtAddr(start) = refineCls.typeRef
val parent = readTpt()
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/mixin-forwarder-clash2.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
1 |class Bar2 extends Bar1 with Two[Foo] // error
| ^
| Name clash between inherited members:
| def concat(suffix: Int): X in trait One and
| def concat: [Dummy](suffix: Int): Y in trait Two
| def concat(suffix: Int): X in trait One at line 4 and
| def concat: [Dummy](suffix: Int): Y in trait Two at line 8
| have the same type after erasure.