-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #6542: Pickle line sizes in TASTy #10363
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,15 +47,13 @@ import scala.annotation.constructorOnly | |
import scala.annotation.internal.sharable | ||
|
||
/** Unpickler for typed trees | ||
* @param reader the reader from which to unpickle | ||
* @param posUnpicklerOpt the unpickler for positions, if it exists | ||
* @param lineSizesUnpicklerOpt the unpickler for line sizes, if it exists | ||
* @param commentUnpicklerOpt the unpickler for comments, if it exists | ||
* @param reader the reader from which to unpickle | ||
* @param posUnpicklerOpt the unpickler for positions, if it exists | ||
* @param commentUnpicklerOpt the unpickler for comments, if it exists | ||
*/ | ||
class TreeUnpickler(reader: TastyReader, | ||
nameAtRef: NameTable, | ||
posUnpicklerOpt: Option[PositionUnpickler], | ||
lineSizesUnpicklerOpt: Option[LineSizesUnpickler], | ||
commentUnpicklerOpt: Option[CommentUnpickler]) { | ||
import TreeUnpickler._ | ||
import tpd._ | ||
|
@@ -1366,9 +1364,9 @@ class TreeUnpickler(reader: TastyReader, | |
val path = sourcePathAt(addr) | ||
if (path.nonEmpty) { | ||
val sourceFile = ctx.getSource(path) | ||
lineSizesUnpicklerOpt match | ||
case Some(lineSizesUnpickler) => | ||
sourceFile.setLineIndices(lineSizesUnpickler.lineIndices) | ||
posUnpicklerOpt match | ||
case Some(posUnpickler) => | ||
sourceFile.setLineIndicesFromLineSizes(posUnpickler.lineSizes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a potential issue here: the relative path of a file is not a unique identifier of the file, there might be path conflicts in the Scala ecosystem. If we also store the hash of source files, that would be better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would you use that hash? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hash would be on the contents of the source? Then we would need to read all the sources eagerly when we add them to the context. That may be quite expensive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we compile files, we already have the file contents in memory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, it is only loaded when we first access something the depends on the source https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/util/SourceFile.scala#L43. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When we compile Scala files, the contents for the Scala files will be forced. |
||
case _ => | ||
pickling.println(i"source change at $addr: $path") | ||
ctx.withSource(sourceFile) | ||
|
Uh oh!
There was an error while loading. Please reload this page.