Skip to content

Commit

Permalink
Add support for mimaReportSignatureProblems (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolgab authored Jul 9, 2022
1 parent 91ea9b7 commit 057e0ac
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,24 @@ Signature:
def mimaForwardIssueFilters: Target[Map[String, Seq[ProblemFilter]]]
```

### IncompatibleSignatureProblem

Most MiMa checks (`DirectMissingMethod`,`IncompatibleResultType`, `IncompatibleMethType`, etc) are against the "method descriptor", which is the "raw" type signature, without any information about generic parameters.

The `IncompatibleSignature` check compares the `Signature`, which includes the full signature including generic parameters. This can catch real incompatibilities, but also sometimes triggers for a change in generics that would not in fact cause problems at run time. Notably, it will warn when updating your project to scala 2.12.9+ or 2.13.1+, see [this issue](https://github.com/lightbend/mima/issues/423) for details.

You can opt-in to this check by setting:

```scala
def mimaReportSignatureProblems = true
```

## Changelog

### 0.0.11

- Add support for `mimaReportSignatureProblems`

### 0.0.10

- Run Mima in a separate classloader.
Expand Down
14 changes: 13 additions & 1 deletion mill-mima/src/com/github/lolgab/mill/mima/MimaBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ private[mima] trait MimaBase
Seq.empty[String]
}

/** If true, report `IncompatibleSignatureProblem`s.
*/
def mimaReportSignatureProblems: Target[Boolean] = T {
false
}

private def mimaWorkerClasspath: T[Agg[os.Path]] = T {
Lib
.resolveDependencies(
Expand Down Expand Up @@ -128,7 +134,13 @@ private[mima] trait MimaBase
def toWorkerApi(p: ProblemFilter) =
new worker.api.ProblemFilter(p.name, p.problem)

val binaryFilters = mimaBinaryIssueFilters().map(toWorkerApi).toArray
val incompatibleSignatureProblemFilters =
if (mimaReportSignatureProblems()) Seq.empty
else Seq(ProblemFilter.exclude[IncompatibleSignatureProblem]("*"))
val binaryFilters =
(mimaBinaryIssueFilters() ++ incompatibleSignatureProblemFilters)
.map(toWorkerApi)
.toArray
val backwardFilters =
mimaBackwardIssueFilters().view
.mapValues(_.map(toWorkerApi).toArray)
Expand Down

0 comments on commit 057e0ac

Please sign in to comment.