Skip to content

Commit 3be25f8

Browse files
authored
Update binary-compatibility-for-library-authors.md
1 parent 05c2c6a commit 3be25f8

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

_overviews/tutorials/binary-compatibility-for-library-authors.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ alice match
255255
Later in time, you can amend the original case class definition to, say, add an optional `address` field. You
256256
* add a new field `address` and a custom `withAddress` method,
257257
* update the public `apply` method in the companion object to initialize all the fields,
258-
* tell MiMa to [ignore](https://github.com/lightbend/mima#filtering-binary-incompatibilities) changes to the class constructor. This step is necessary because MiMa does not yet ignore changes in private class constructor signatures (see [#738](https://github.com/lightbend/mima/issues/738)).
259258

260259
{% tabs case_class_compat_4 class=tabs-scala-version %}
261260
{% tab 'Scala 2' %}
@@ -284,28 +283,6 @@ object Person:
284283
{% endtab %}
285284
{% endtabs %}
286285

287-
And, in your build definition:
288-
289-
{% tabs case_class_compat_5 %}
290-
{% tab 'sbt' %}
291-
~~~ scala
292-
import com.typesafe.tools.mima.core._
293-
mimaBinaryIssueFilters += ProblemFilters.exclude[DirectMissingMethodProblem]("Person.this")
294-
~~~
295-
{% endtab %}
296-
{% endtabs %}
297-
298-
Otherwise, MiMa would fail with an error like “method this(java.lang.String,Int)Unit in class Person does not have a correspondent in current version”.
299-
300-
> Note that an alternative solution, instead of adding a MiMa exclusion filter, consists of adding back the previous
301-
> constructor signatures as secondary constructors:
302-
> ~~~ scala
303-
> case class Person private (name: String, age: Int, address: Option[String]):
304-
> ...
305-
> // Add back the former primary constructor signature
306-
> private[Person] def this(name: String, age: Int) = this(name, age, None)
307-
> ~~~
308-
309286
The original users can use the case class `Person` as before, all the methods that existed before are present unmodified after this change, thus the compatibility with the existing usage is maintained.
310287

311288
The new field `address` can be used as follows:

0 commit comments

Comments
 (0)