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

Let rules expose scala versions constraints #1199

Open
bjaglin opened this issue Jul 3, 2020 · 0 comments
Open

Let rules expose scala versions constraints #1199

bjaglin opened this issue Jul 3, 2020 · 0 comments

Comments

@bjaglin
Copy link
Collaborator

bjaglin commented Jul 3, 2020

Advanced semantic rules such as ExplicitResultTypes or ExplicitNonNullaryApply using the presentation compiler via ScalafixGlobal require the build scalaVersion to match scalafixScalaBinaryVersion, and potentially the full Scala release used by Scalafix.

Rules themselves should not suggest actions to fix a mismatch (as rules might not be run from sbt for example). That should be up to the rules runner (mill, sbt, CLI, metals, etc), which should be able to intercept information upon execution failure and derive a relevant call for action, or even update state automatically (maybe with a warning saying it should be made persistent).

Implementation: I am not sure the return type of https://www.javadoc.io/static/ch.epfl.scala/scalafix-core_2.12/0.9.18/scalafix/v1/SemanticRule.html#withConfiguration(config:scalafix.v1.Configuration):metaconfig.Configured[scalafix.v1.Rule] is rich enough to allow that level of information, so we need to discuss how this could be implemented in a backward-compatible way. Suggestion:

// Rule.scala

 // making it non-sealed will force clients to pattern-match `_` and be forward compatible
/*sealed*/ trait InputRequirement
case class BinaryScalaVersion(binaryScalaVersion: String) extends InputRequirement
case class ScalaVersion(scalaVersion: String) extends InputRequirement
case class RequiredScalacOption(scalacOption: String) extends InputRequirement
case class IncompatibleScalacOption(scalacOption: String) extends InputRequirement
...

protected def failedRequirements(
  inputScalaVersion: String,
  inputScalacOptions: String
): List[InputCompilationRequirement]) = Nil

Somewhat related to #1143

@bjaglin bjaglin changed the title Expose scala versions mismatch as typed errors in SemanticRule#withConfiguration Expose scala versions mismatch as typed errors in Rule#withConfiguration Jul 3, 2020
@bjaglin bjaglin changed the title Expose scala versions mismatch as typed errors in Rule#withConfiguration Let rules expose scala versions constraints Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant