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

Router: use template to break before extends #3581

Merged
merged 1 commit into from
Jul 7, 2023

Conversation

kitbellew
Copy link
Collaborator

In older versions of scalameta, extends was not part of template, and we had to identify the tree just preceding it.

Also, make sure to handle cases when the template is empty (in that case there's no reason to break before a non-existent extends).

Fixes #3580.

@kitbellew kitbellew requested a review from tgodzik July 7, 2023 15:05
In older versions of scalameta, `extends` was not part of template, and
we had to identify the tree just preceding it.

Also, make sure to handle cases when the template is empty (in that case
there's no reason to break before a non-existent `extends`).
@kitbellew kitbellew merged commit 5bfe04b into scalameta:master Jul 7, 2023
8 checks passed
@kitbellew kitbellew deleted the 3580 branch July 7, 2023 17:05
@SethTisue
Copy link
Contributor

@kitbellew do you think it would be appropriate for us to say something about this in the Scala 2.13.12 release notes? and if so, can you suggest a wording?

@kitbellew
Copy link
Collaborator Author

@SethTisue oh, what did I miss? how's this related to that scala release?

@SethTisue
Copy link
Contributor

#3580 was reported against a nightly build of Scala 2.13.12, after scala/scala#10392 was merged. I'm asking if we have a situation where users who upgrade Scala 2.13.12 will also need to upgrade their Scalafmt version in order to format their code.

(It's possible I have some misconception.)

@kitbellew
Copy link
Collaborator Author

@SethTisue I think the problem was because scalafmt was rebuilt and re-tested (and failed) with the new scala version, as part of that community build. but the released version of scalafmt hadn't been built with that version (and the released version of scalafmt hadn't failed the same tests), so it doesn't seem like it would have real-world consequences. @tgodzik what do you think?

@tgodzik
Copy link
Contributor

tgodzik commented Aug 24, 2023

Yeah, I agree that this shouldn't be an issue. The last used by version compiled with the last version, should be done one from scalameta, so no issues should show up a different scala version is on classpath.

mbland added a commit to mbland/rules_scala that referenced this pull request Oct 1, 2024
As it turns out, we're using a very old version of Scalafmt that breaks
completely:

```txt
ERROR: rules_scala/test/scalafmt/BUILD:43:20:
  ScalaFmt test/scalafmt/test/scalafmt/formatted/formatted-test.scala.fmt.output failed:
  (Exit 1): scalafmt failed: error executing ScalaFmt command
  (from target //test/scalafmt:formatted-test)
bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/scala/scalafmt/scalafmt
  '--jvm_flag=-Dfile.encoding=UTF-8' ... (remaining 1 argument skipped)

java.util.NoSuchElementException: last of empty IndexedSeq
```

This matches:

- scala/community-build#1680

Which mentions apparent fixes in:

- scalameta/scalameta#3235
- scalameta/scalafmt#3581

So the fix is to update Scalafmt, but given how we don't use
rules_jvm_external, that means a lot of manual updates to
third_party/repositories/scala_*.bzl. There doesn't appear to be a way
to automate this; there's no indication that the most recent update was
automated in any way:

- bazelbuild#1543

So I'll plow through all the JARs and make the necessary changes:

- https://mvnrepository.com/artifact/org.scalameta/scalafmt-core

I can't update scala_2_11, since there's not a more recent compatible
version. But the changes to scala_2_12 and scala_2_13 should be similar,
and the changes to 2_13 should apply to 3_{1,2,3,4} as well.

I had to hack .scalafmt.conf and ScalafmtWorker.scala a bit. This may
make it incompatible with 2.11.
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.

Unit test failures on 2.13.12
3 participants