-
Notifications
You must be signed in to change notification settings - Fork 17
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
Feed to whole classpath to scalafix and fix ExplicitResultTypes
#172
Conversation
ExlicitResultTypes
fixExlicitResultTypes
fix
ExlicitResultTypes
fixExlicitResultTypes
ExlicitResultTypes
ExplicitResultTypes
I tried to fix the issue by applying the findings of @bjaglin in #174 (comment) and the details of the Javadoc comments for /**
* @param classpath Full Java classpath of the module being fixed. Required for running
* semantic rewrites such as ExpliticResultTypes. Source files that
* are to be fixed must be compiled with the semanticdb-scalac compiler
* plugin and must have corresponding <code>META-INF/semanticdb/../*.semanticdb</code>
* payloads. The dependency classpath must be included as well but dependency
* sources do not have to be compiled with semanticdb-scalac.
*/
ScalafixArguments withClasspath(List<Path> classpath); This indeed makes the
|
This reproduces an issue discovered in a Mill PR * com-lihaoyi/mill#2922
b840857
to
2aa70ec
Compare
Although, I have now idea, why this didn't fail before, I think the issue is, that we can't feed extra semanticDb options via Instead, we need to customize the options specific for the But I think we can override the |
Looks like the Here are our options:
I think option 1. is the most straight forward actionable options. Additionally, we might strive for option 4. Another workaround for the custom rules features in Mill 0.10 might be to explicitly add the semanticDb plugin to the project, such that it is available in the default compilation and can be customized via |
This makes it accessible for downstream tooling. * Use case: joan38/mill-scalafix#172 Essentially, this is a backport of what we have in Mill 0.11, so this PR is in the spirit of the previous pull requests we merged. Pull request: #2951
As a result, from my outsider Scalafix perspective (not taking into account Mill 0.10 vs 0.11 usage), I'd say that (1) is the most pragmatic choice as downside is very limited for a big upside: better enable the built-in |
Looking at the fix, I was wondering how the incremental compiler handles a regular compilation concurrent to the semantidcb-output one, as introduced by this PR. A quick look at How much do they benefit from each other and how does their order impact the incremental gain? Considering the overhead of semanticdb-scalac, I assume the design rationale behind the 2 separate compilations was that it is beneficial to postpone the semantidcb-output one (potentially to "never"). However, for cold scalafix invocations, the extra compilation may become a significant overhead on large projects.
This functional workaround would also address the performance consideration above I believe. I assume mill-scalafix could then override |
In Mill, |
Both tasks are independent but take profit from previous runs (they are incremental) as well as the upstream zinc analysis data.
The semanticDb compiler invocation just stops after the phase that generates/writes the semanticDb data, so the overhead is lower then you might think. And in a large project with multiple modules, the compiler is already hot after a small amount of module compilations, so it's not that bad.
Mill could be more clever in
No problem and Kudos for doing that. I hope you enjoyed it and try out Mill someday. |
I went with option 3. I tagged Mill 0.10.14 which will contain com-lihaoyi/mill#2951. Once, it is released, I will update this PR. |
@@ -12,7 +12,7 @@ import mill.scalalib.api.ZincWorkerUtil.scalaNativeBinaryVersion | |||
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl} | |||
import scalalib._ | |||
|
|||
val millVersions = Seq("0.10.12", "0.11.1") | |||
val millVersions = Seq("0.10.15", "0.11.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We depend on new API since Mill 0.10.15.
@@ -3,6 +3,6 @@ import com.goyeau.mill.scalafix.ScalafixModule | |||
import mill.scalalib._ | |||
|
|||
object project extends ScalaModule with ScalafixModule { | |||
def scalaVersion = "2.13.6" | |||
def scalaVersion = "2.13.10" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Necessary to make test succeed.
Pretty cool indeed! I'll definitely keep an eye on whether you manage to pull a
Makes sense. #175 is a lower-hanging fruit anyway if performance ever becomes a concern.
I definitely did enjoy the design. At the very least I'm gonna watch the mill-scalafix repo and chime-in when I can help. Thanks for your answers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from a Scalafix perspective 👍
@@ -25,7 +25,7 @@ trait ScalafixModule extends ScalaModule { | |||
T.ctx().log, | |||
repositoriesTask(), | |||
filesToFix(sources()).map(_.path), | |||
Seq(semanticDbData().path), | |||
classpath = (compileClasspath() ++ localClasspath() ++ Seq(semanticDbData())).iterator.toSeq.map(_.path), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A potential further improvement to reduce the added overhead would be to avoid triggering any compilation if none of the rules is semantic (rulesThatWillRun.exists(_.kind.isSemantic)
) like it's done in sbt-scalafix. Not sure how/if this (dynamic tasks in sbt) can be achieved in Mill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be tricky, as the task graph can't be changed once it has started. But we have some options at construction time, depending on how lightweight (fast) a check can be.
Anyways, this should be done in a separate PR.
I tested this PR on com-lihaoyi/mill#2922 and it now properly changes the code with missing type annotations. |
I released |
Feed the whole classpath to scalafix, which is needed for some scalafix rules like
ExplicitReusltTypes
to work correctly.Added the
ExplicitResultTypes
rule to the integration test to reproduces the initial issue discovered in a Mill PR (github.com/com-lihaoyi/mill/pull/2922) and make sure we correctly handle it.Fix #174
This PR also raises the minimal supported Mill version to 0.10.15, as this is the fist release which makes the
ScalaModule.semanticDbEnablePluginScalacOptions
task accessible for inheriting modules.