Skip to content

Fix #10883: Override line and column in NoSourcePosition #11362

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 2 commits into from
Feb 12, 2021

Conversation

griggt
Copy link
Contributor

@griggt griggt commented Feb 9, 2021

The REPL driver uses the line and column methods of SourcePosition for ordering its output, however there are several diagnostics that are reported using NoSourcePosition, for example:

https://github.com/lampepfl/dotty/blob/a63b1d114179d79be32a1ee6552fc160c1bb2410/compiler/src/dotty/tools/dotc/Run.scala#L256
https://github.com/lampepfl/dotty/blob/a63b1d114179d79be32a1ee6552fc160c1bb2410/compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala#L345

This was working until the SourcePosition implementation was changed in #10363, after which calls to line or column on NoSourcePosition resulted in an assertion error rather than returning -1 in accordance with:

https://github.com/lampepfl/dotty/blob/a63b1d114179d79be32a1ee6552fc160c1bb2410/interfaces/src/dotty/tools/dotc/interfaces/SourcePosition.java#L20-L23

Fixes #10883
Fixes #9111 (previously fixed by #9351, broken again by #10363)

This permits constructing tests that depend on particular command
line options such as `-Xprint:typer`
Otherwise, usage causes an assertion error.

The use of the value -1 is in agreement with the documentation in
interfaces/src/dotty/tools/dotc/interfaces/SourcePosition.java

The REPL driver depends on these methods for ordering its output, and
some diagnostics are reported (intentionally) using NoSoucePosition.
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@liufengyun liufengyun merged commit 73d34fd into scala:master Feb 12, 2021
@griggt griggt deleted the fix-#10883 branch February 12, 2021 15:44
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

REPL: missing span with valid code and -Xprint:<some phase> NoSpan in console
3 participants