Open
Description
I encountered this when writing a Mill plugin. When creating an ExternalModule
you'll have code that looks like this:
import mill._
import mill.define.Command
import mill.define.ExternalModule
import mill.eval.Evaluator
import mill.main.EvaluatorScopt
object Example extends ExternalModule {
def foo(ev: Evaluator): Command[Unit] = T.command {}
implicit def millScoptEvaluatorReads[T]: EvaluatorScopt[T] =
new mill.main.EvaluatorScopt[T]()
lazy val millDiscover = mill.define.Discover[this.type]
}
If you run scalafix against this wanting ExplicitResultTypes
you'll end up with broken code since the final lazy vall millDiscover
will turn into:
lazy val millDiscover: Discover[Example] = mill.define.Discover[this.type]
Which will error with:
not found: type Example
I'd expect running this rule not to break my code.
You can reproduce this with the Scala file up above placed in a foo/src/Example.scala
and the following files:
// build.sc
import mill._
import scalalib._
import mill.scalalib.api.ZincWorkerUtil
import $ivy.`com.goyeau::mill-scalafix::0.2.8`
import com.goyeau.mill.scalafix.ScalafixModule
object foo extends ScalaModule with ScalafixModule {
def scalaVersion = "2.13.8"
def scalafixScalaBinaryVersion =
ZincWorkerUtil.scalaBinaryVersion(scalaVersion())
override def compileIvyDeps = super.compileIvyDeps() ++ Agg(
ivy"com.lihaoyi::mill-scalalib:0.10.5"
)
}
// .scalafix.conf
rules = [
ExplicitResultTypes
]
Then you can either run them via Mill or Metals.