Try using -Ymagic-offset-header to fixup line numbers#5932
Try using -Ymagic-offset-header to fixup line numbers#5932lihaoyi wants to merge 14 commits intocom-lihaoyi:mainfrom
-Ymagic-offset-header to fixup line numbers#5932Conversation
|
Next blocker seems to be that Mill's codegen desugars object `package` extends mill.Module {abstract class package_ extends _root_.mill.util.MainRootModule, mill.Module {This didn't affect the old error position fixup mechanism because it was line based, but the new one is offset based and so the longer line screws up all the subsequent offsets |
eead679 to
ae2002d
Compare
|
Seems we might not be able to merge this until Mill 2.x, as the new codegen would require that Fixable, but would break binary compatibility to fix |
318414b to
dce77b0
Compare
|
Got most tests passing with a modified codegen strategy, but will need to wait for Scala 3.8.0 to land with scala/scala3#24301 before we can merge this since that PR will likely miss 3.7.4 |
adc3bd9 to
2865580
Compare
|
Can't land this yet because scala/scala3#24301 hasn't made it into 3.8.0-RC2 |
febd40b to
a004b45
Compare
f728354 to
856984d
Compare
65c14fa to
943d7b6
Compare
aec5708 to
fa73b57
Compare
|
Now blocked on scala/scala3#25706 |
This 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