Skip to content

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

Merged
merged 1 commit into from
Mar 4, 2020

Conversation

tgodzik
Copy link
Contributor

@tgodzik tgodzik commented Mar 4, 2020

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.

Copy link
Member

@dottybot dottybot left a 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
Copy link
Member

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.

Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@tgodzik tgodzik requested a review from smarter March 4, 2020 15:41
@smarter smarter merged commit 0954a07 into scala:master Mar 4, 2020
@tgodzik tgodzik deleted the fix-off-by-one branch March 4, 2020 17:17
@tgodzik
Copy link
Contributor Author

tgodzik commented Mar 4, 2020

Thanks @smarter !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants