Use full file path for parse error messages and compiler metadata #1233
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #646
Fixes #493
Previously we constructed a
new io.VirtualFile
with an identical name and path, both short, to ensure stack traces included only the file name. The correct thing to do is to provide separate names and paths, so stack traces can use the file name while compiler errors can use the full file path. This is done differently in Scala2 and Scala3 due to differences in the compiler APIs, but the end result is the sameThis makes the parse/compile errors line up more with how the normal Scala compiler reports them, and fixes
sourcecode.File
to properly report the full path of the script file.Updated the existing LineNumberTests to verify the fixed behavior, and added a new
sourceCodeMetadata.sc
test case to verify the fix applies to thesourcecode.*
macros. For nowsourcecode.*
macros do not work in the REPL or scripts in Scala3, but that is an unrelated problem we can deal with laterReview by @alexarchambault and @anatoliykmetyuk