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

Make ExplicitResultTypes work with more Scala versions #998

Closed
olafurpg opened this issue Nov 30, 2019 · 4 comments · Fixed by #1167
Closed

Make ExplicitResultTypes work with more Scala versions #998

olafurpg opened this issue Nov 30, 2019 · 4 comments · Fixed by #1167
Assignees
Milestone

Comments

@olafurpg
Copy link
Contributor

Unlike other rules, ExplicitResultTypes only works with Scala 2.12.10 at the moment because the rule interfaces directly with the presentation compiler. It would be great if we could add support for Scala 2.13 and 2.11 but doing so would require rethinking how rules are compiled/published/launched.

  • should Scalafix rules be cross-built against multiple Scala versions if they want to use the presentation compiler API? This would require changing sbt-scalafix to launch the correct Scalafix version (2.11/2.12/2.13) depending on the project being fixed.
  • should Scalafix provide an Java-API on top of the presentation compiler allowing 2.12-compiled rules to work with 2.13/2.11? We use this approach in Metals (the server runs in 2.12, but completions work with 2.11/2.12/2.13).

I'm inclined to do the second approach since I like that Scalafix rules can work regardless of the Scala version being fixed. Regardless of the approach we use, I estimate it will require non-trivial work to implement.

@mlachkar
Copy link
Collaborator

mlachkar commented Jun 4, 2020

in 2.13, instead of Serializable, the type found is AnyRef. code example :

  val access: Serializable = new Serializable {
    private val results: List[Int] = List.empty
    protected val results2: List[Int] = List.empty
  }

@bjaglin
Copy link
Collaborator

bjaglin commented Jun 4, 2020

@mlachkar not sure I follow, you mean that the rule as it's currently written has some bugs only present when ran against scala 2.13 sources? Is that a case of scalacenter/sbt-scalafix#121 (comment) ?

@mlachkar
Copy link
Collaborator

mlachkar commented Jun 4, 2020

When I cross compiled this rule to 2.13, this test broke. This rule is not working for all cases that were supported in 2.12.
I was not able to fix all rules, and I thought I will do this work in other PRs before v1.

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