-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add +1 to zinc positions in the compiler bridge #8434
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
val line = mainProblem.position().line() | ||
assert(line.isPresent() == true) | ||
assert(line.get() == 9) | ||
|
||
// Assert disabled because we don't currently pass positions to sbt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that assert can be reenabled now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reenabled the assert.
@@ -88,7 +88,7 @@ public void doReport(MessageContainer cont, Context ctx) { | |||
else return Optional.ofNullable(src.file().path()); | |||
} | |||
public Optional<Integer> line() { | |||
int line = pos.line(); | |||
int line = pos.line() + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do anything for columns? Either way a test would be welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've seen the columns are correct. I will add a test for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Thanks @smarter ! |
In the previous version of the compiler bridge we were adding 1 here:
https://github.com/sbt/zinc/blob/fc58a39402ca7abfda17133a5b3a43de3344ca49/internal/compiler-bridge/src/main/scala/xsbt/DelegatingReporter.scala#L99
which means Zinc expects line numbers starting at 1, while in Dotty we provided it with ones starting at 0.
This wasn't an issue when using dotc and sbt, since dotc added 1 to show the correct line number and sbt most likely used the Dotty rendered message due to:
https://github.com/sbt/zinc/pull/699/files?diff=unified&w=1
This popped up when adding some test in Bloop: tgodzik/bloop#1
Let me know if we should fix it differently. This is needed for the work I am doing on the Metals/Dotty integration.