Skip to content

Commit 3cfc5ef

Browse files
committed
@stableabi: improve introduction.
1 parent b6d57c0 commit 3cfc5ef

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

sips/pending/_posts/2017-01-13-binary-compatibility.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ __first submitted 13 January 2017__
1313
Scala is a language which evolves fast and thus made a decision to only promise binary compatibility across minor releases\[[3]\].
1414
At the same time, there is a demand to develop APIs that live longer than a major release cycle of Scala.
1515
This SIP introduces an annotation `@stableABI` that checks that `what you write is what you get`.
16-
It will fail compilation in case compilation scheme of this class requires changes to methods signatures,
17-
making them different from those written by developers and introducing implicit dependency on version of this desugaring.
1816

17+
`@stableABI` is a linter, that does not change binary output, but will fail compilation if Public API of a class uses features
18+
of Scala that are desugared by compiler and may be binary incompatible across major releases.
19+
1920
As long as declarations in source have not changed, `@stableABI` annotated class will be compatible across major versions of Scala.
20-
21+
It complements MiMa\[[2]\] in indicating if a class will remain binary compatible across major Scala releases.
2122

2223
## Term definitions
2324
* #####Binary descriptors
@@ -58,8 +59,10 @@ As long as declarations in source have not changed, `@stableABI` annotated class
5859
2. Defining a class which is supposed to be also used from other JVM languages such as Java\Kotlin.
5960
`@stableABI` will ensure both binary compatibility and that there are no unexpected methods
6061
that would show up in members of a class or an interface.
62+
3. Library authors can take advantage of language features introduced in new major versions of Scala
63+
while still serving users on older language versions by defining their Public API as `@stableABI`.
6164

62-
The biggest use-case envisioned here by the authors is migration to Dotty.
65+
The important use-case envisioned here by the authors is migration to Dotty.
6366
We envision that there might be code-bases that for some reason don't compile either with Dotty or with Scalac.
6467
This can be either because they rely on union types, only present in Dotty,
6568
or because they need early initializers, which are only supported by Scalac.
@@ -83,7 +86,7 @@ These interfaces can be replaced by `@stableABI` annotated traits to reach the s
8386
## Design Guidelines
8487
`@stableABI` is a feature which is supposed to be used by a small subset of the ecosystem to be binary compatible across major versions of Scala.
8588
Thus this is designed as an advanced feature that is used rarely and thus is intentionally verbose.
86-
It's designed to provide strong guarantees, in some cases sacrificing ease of use.
89+
It's designed to provide strong guarantees, in some cases sacrificing ease of use and be used in combination with MiMa\[[2]\]
8790

8891
The limitations enforced by `@stableABI` are designed to be an overapproximation:
8992
instead of permitting a list of features known to be compatible, `@stableABI` enforces a stronger
@@ -155,7 +158,7 @@ Note that while those features are prohibited in the public API, they can be saf
155158

156159
- public fields. Can be simulated by explicitly defining public getters and setters that access a private field;
157160
- lazy vals. Can be simulated by explicitly writing an implementation in source;
158-
- case classes. Can be simulated by explicitly defining getters and other members synthesized for a case class(`copy`, `productArity`, `apply`, `unApply`, `unapply`).
161+
- case classes. Can be simulated by explicitly defining getters and other members synthesized for a case class(`copy`, `productArity`, `apply`, `unapply`, etc).
159162

160163
The features listed below cannot be easily re-implemented in a class or trait annotated with `@stableABI`.
161164
- default arguments;
@@ -201,7 +204,8 @@ as well as methods and implicit conversions imported from `scala` and `Predef`.
201204
As such Standard library is expected would be the biggest source of warnings defined in previous section.
202205

203206
We propose to consider either making some classes in standard library use `@stableABI` or define new `@stableABI`
204-
super-interfaces for them that should be used in `@stableABI` classes. This would also allow to consume Scala classes from other JVM languages such as Kotlin and Java.
207+
super-interfaces for them that should be used in `@stableABI` classes.
208+
This would also allow to consume Scala classes from other JVM languages such as Kotlin and Java.
205209
## `@stableABI` and Scala.js
206210

207211
Allowing to write API-defining classes in Scala instead of Java will allow them to compile with Scala.js,

0 commit comments

Comments
 (0)