Try using -Ymagic-offset-header to fixup line numbers
#5932
+96
−352
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.
Requires
3.7.4-RC2for now, but will need to wait until3.7.4-finalbefore landingThis flag lets us remove a lot of our sketchy user-land workarounds to fix the filename and line numbers of errors:
AsmPositionUpdaterto which handled runtime exception error positionsPositionalMapperandTransformingReporterwhich handled compile-time error positions//SOURCECODE_ORIGINAL_FILE_PATHand//SOURCECODE_ORIGINAL_CODE_START_MARKER, which handledsourcecode.File/sourcecode.LinepositioningThis replaces it with a single
///SOURCE_CODE_STARTcomment referenced by-Ymagic-offset-header:SOURCE_CODE_START, which hooks in early enough in the compiler pipeline that all these downstream use cases can rely on itThe new
///SOURCE_CODE_STARTcomment relies on character offsets unlike line numbers like the previous hacks, and so we needed to change ourCodeGen.scalacode to avoid mangling lines within the user code block. Concretely, we needed to stop translatingobject packageintoabstract class package extends blahblahblah. Instead we translateobject packageintoclass _package(which takes up the same number of characters to avoid affecting offsets) and move theextends blahblahblahinto the generated code above the///SOURCE_CODE_STARTheader