Scalafix cross-compiled for Scala 3 (GSoC 2022)

Hey Scala Community,

We’re happy to announce that as part of GSoC 2022 we managed to cross-compile Scalafix to Scala 3!
If you don’t know yet, Scalafix is a linting, and code rewriting tool for Scala codebases. :partying_face:

So far Scalafix is available for Scala versions 2.11, 2.12 and 2.13, but with my contribution to Scalafix as part of GSoC 2022 we just merged the cross compilation of Scalafix to Scala 3.

Benefits to the Community
The reasons for porting Scalafix to Scala 3 are:

  • Scalafix built-in and community rules can be written directly in Scala 3
  • It enables the implementation of ExplicitResultTypes rule for Scala 3

New Scalafix release and next steps
Scalafix cross-compiled to Scala 3 isn’t published yet, here you can see the related Github issue for publishing scalafix-cli_3. However this new Scalafix version will not support the ExplicitResultTypes rule.
Why so? Because the ExplicitResultTypes rule uses the compiler in order to infer the Types of the members. Hence due to the different compilers between Scala 2 and Scala 3 (dotty) the ExplicitResultTypes rule needs to be rewritten using the new compiler.

The roadmap :railway_track: for the next steps follows:

  • Publishing a new Scalafix version for Scala 3, without ExplicitResultTypes
  • Implement ExplicitResultTypes using the dotty compiler
  • Make scalafix-cli_3 fallback on loading 2.13 artifacts for requested community rules
  • Advocate for community rules to cross compile to Scala 3 by updating:
  • Support for running scalafix-cli_3 in sbt-scalafix plugin

Thanks
Big thanks to @mlachkar and @bjaglin for mentoring during the GSoC project, and for the awesome community in Discord. :pray:

Contributions
All contributions are welcome, feel free to get in touch with us :slight_smile:

10 Likes

Congratulations!

1 Like

A summer well-spent! Great work!

1 Like