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

Pass -Xsource:3 to scalafix organize-imports action if present #3574

Merged
merged 1 commit into from Jan 28, 2022
Merged

Pass -Xsource:3 to scalafix organize-imports action if present #3574

merged 1 commit into from Jan 28, 2022

Conversation

hugo-vrijswijk
Copy link
Contributor

@hugo-vrijswijk hugo-vrijswijk commented Jan 28, 2022

When using organize-imports on Scala 2 with -Xsource:3 a crash would occur when using as import renaming:

2022.01.28 11:08:13 ERROR /..../ConfigReader.scala:8: error: } expected but identifier found
import pureconfig.{ConfigReader as PureConfigReader, ConfigSource}

This is because Scalafix tries to parse the file as Scala 2. Scalafix has support for -Xsource:3 since scalacenter/scalafix#1409 but it needs to be passed in the scalacOptions. With this fix -Xsource:3 is passed to Scalafix if used, fixing the crash and letting Scalafix properly parse and fix the file.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! Let's see if the CI passes, then we should be good to merge!

@hugo-vrijswijk
Copy link
Contributor Author

Thanks! This has been a minor annoyance since using -Xsource:3 and was a surprisingly easy fix!

@tgodzik tgodzik merged commit 34d9f28 into scalameta:main Jan 28, 2022
@hugo-vrijswijk hugo-vrijswijk deleted the fix/source3-organize-imports branch January 28, 2022 14:58
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.

None yet

2 participants