Skip to content
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

Self-type indentation is unexpectedly significant #9515

Closed
som-snytt opened this issue Aug 7, 2020 · 1 comment · Fixed by #10330
Closed

Self-type indentation is unexpectedly significant #9515

som-snytt opened this issue Aug 7, 2020 · 1 comment · Fixed by #10330
Milestone

Comments

@som-snytt
Copy link
Contributor

Minimized code

trait C {
self =>

  class D

  class E
}

Output

-- Warning: badindent.scala:9:2 ------------------------------------------------
9 |  class E
  |  ^
  |  Line is indented too far to the right, or a `{` or `:` is missing
1 warning found

IRL, source had a few indentation quirks, so it can be tricky-to-impossible to locate the offender 800 lines back.

[info] Compiling 61 Scala sources to .../target/scala-0.26/classes ...
[warn] -- Warning: .../src/main/scala/scala/collection/parallel/ParIterableLike.scala:888:2 
[warn] 888 |  protected[this] abstract class Composite[FR, SR, R, First <: StrictSplitterCheckTask[FR, _], Second <: StrictSplitterCheckTask[SR, _]]
[warn]     |  ^
[warn]     |  Line is indented too far to the right, or a `{` or `:` is missing

Expectation

The problem is the indentation of the self type.

It is not obvious whether the indentation of the self type should matter.

The warning should tell me why it thinks my indentation is wrong, i.e., which previous line established the expected indentation.

The warning is due to the template class D checking the indentation of the following line, which is class E.

Maybe the extra help, e.g., mentioning is misaligned with line 3, should be enabled under a flag.

odersky added a commit to dotty-staging/dotty that referenced this issue Nov 16, 2020
The indentation of the self type does not matter anymore; it's the next token after
the `=>` that determines the indentation width.
@odersky
Copy link
Contributor

odersky commented Nov 16, 2020

It is not obvious whether the indentation of the self type should matter.

I fixed it so that it does not matter.

@nicolasstucki nicolasstucki linked a pull request Nov 16, 2020 that will close this issue
nicolasstucki added a commit that referenced this issue Nov 16, 2020
Fix #9515: Fix handling of selftype for indentation
@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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants