If I change this
trait Parent {
def foo() = 1
}
trait Child extends Parent {
override def foo() = 2
}
to this
trait Parent {
def foo() = 1
}
trait Child extends Parent {
override def foo() = super.foo() + 1
}
MIMA’s binary compat checker fails with
Found 1 issue when checking against com.lihaoyi:foo1:VersionConstraint.Lazy(0.0.1, VersionInterval(None, None, false, false), Some(Version(0.0.1)), None)
* abstract synthetic method Child$$super$foo()Int in interface Child is present only in current version
filter with: ProblemFilter.exclude[ReversedMissingMethodProblem]("Child.Child$$super$foo")
This causes considerable inconvenience in Mill, where changing the implementation of something to call super is not uncommon. It can be worked around by doing something like
trait Parent {
def fooNewHelper() = 1
def foo() = fooNewHelper()
}
trait Child extends Parent {
override def foo() = fooNewHelper() + 1
}
But doing these workarounds is super annoying
Two questions:
- Is this a real error that I need to be worried about? Like if I publish one of these changes, will my users start seeing
MethodNotFounderrors? Or is it an incidental change that doesn’t actually break things? - Can it be fixed somehow so changing the implementation of a method does not randomly cause a new abstract method to be generated, and break binary compatibility?
For a repro, create a Mill project with a ./mill script and:
build.mill
//| mill-version: 1.0.0
//| mvnDeps: [com.github.lolgab::mill-mima_mill1:0.2.0]
import mill._, scalalib._, publish._, com.github.lolgab.mill.mima.Mima
object foo1 extends ScalaModule with PublishModule{
def scalaVersion = "3.7.1"
def publishVersion = "0.0.1"
def pomSettings = PomSettings(
description = "Main method argument parser for Scala",
organization = "com.lihaoyi",
url = "https://github.com/com-lihaoyi/unroll",
licenses = Seq(License.MIT),
versionControl = VersionControl.github("com-lihaoyi", "unroll"),
developers = Seq(Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi"))
)
}
object foo2 extends ScalaModule with Mima{
def scalaVersion = "3.7.1"
def mimaPreviousArtifacts = Task { Seq(mvn"com.lihaoyi::foo1:0.0.1") }
}
foo1/src/MyTrait.scala
trait Parent {
def foo() = 1
}
trait Child extends Parent {
override def foo() = 2
}
foo2/src/MyTrait.scala
trait Parent {
def foo() = 1
}
trait Child extends Parent {
override def foo() = super.foo() + 1
}
And run
./mill foo1.publishLocal
./mill foo2.mimaReportBinaryIssues