Skip to content

Commit 1ac1904

Browse files
committed
binCompat: clarifications of compilation scheme.
1 parent fd907c4 commit 1ac1904

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,15 @@ As long as declarations in source have not changed, `@stableABI` annotated class
4747

4848
In this document we use term `Public API` to refer both to methods and fields defined as `ACC_PUBLIC` and `ACC_PROTECTED`.
4949
Changes do binary descriptors of Public API may lead to runtime linkage failures.
50-
* ####Binary compatibility
50+
* #####Binary compatibility
5151

5252
Two versions of the same class are called binary compatible if there are no changes to the Public API of this class,
5353
meaning that those two classes can be substituted in runtime without linkage errors.
5454

5555
## Use cases
5656

57-
2. Defining a class which is supposed to be also used from Java\Kotlin.
57+
1. Publishing a library that would work across major Scala versions, such as 2.12 & 2.13 and Dotty.
58+
2. Defining a class which is supposed to be also used from other JVM languages such as Java\Kotlin.
5859
`@stableABI` will ensure both binary compatibility and that there are no unexpected methods
5960
that would show up in members of a class or an interface.
6061

@@ -70,9 +71,6 @@ SBT additionally compiles on demand the compiler bridge, which implements this J
7071
2. Dotty\[[7]\] currently uses java defined interfaces as public API for IntelliJ in order to ensure binary compatibility.
7172
These interfaces can be replaced by `@stableABI` annotated traits to reach the same goal.
7273

73-
74-
75-
7674
## Design Guidelines
7775
`@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.
7876
Thus this is designed as an advanced feature that is used rarely and thus is intentionally verbose.
@@ -163,7 +161,13 @@ which would have benefit of sharing the same source for two ecosystems.
163161

164162
Scala.js currently is binary compatible as long as original bytecode compiled by Scala JVM is binary compatible.
165163
Providing stronger binary compatibility guarantees for JVM will automatically provide stronger guarantees for Scala.js.
164+
165+
166+
## Binary compatibility and transitivity ##
167+
TODO
166168

169+
## The case of the standard library ##
170+
TODO
167171

168172
## Comparison with MiMa ##
169173
The Migration Manager for Scala (MiMa in short) is a tool for diagnosing binary incompatibilities for Scala libraries.
@@ -184,13 +188,17 @@ This provides early guidance and warning when designing long-living APIs before
184188

185189
## Compilation scheme ##
186190
No modification of typer or any existing phase is planned. The current proposed scheme introduces a late phase that runs before the very bytecode emission that checks that:
187-
- classes and traits annotated as `@stableABI` are on the top level;
188-
- no non-private members where introduced inside classes and traits annotated as `@stableABI` by compiler using phase travel;
189-
- no non-private members inside classes and traits annotated as `@stableABI` has changed their binary descriptor from the one written by developer.
191+
- classes, traits and objects annotated as `@stableABI` are on the top level;
192+
- compiler did not introduce new Public API methods or fields inside `@stableABI` classes, traits and objects;
193+
- compiler did not change descriptors of existing Public API methods or fields inside `@stableABI` classes, traits and objects.
194+
195+
This phase additionally warns if Public API method or field takes an argument or returns a value that isn't marked as `@stableABI`.
196+
This warning can be suppressed by annotating with `@unchecked`.
190197

191-
The current prototype is implemented for Dotty and supports everything described in this SIP.
198+
The current prototype is implemented for Dotty and supports everything described in this SIP, except warnings.
192199
The implementation is simple with less than 50 lines of non-boilerplate code.
193-
The current implementation has a scope for improvement of error messages that will report domain specific details for disallowed features, but it already prohibits them.
200+
The current implementation has a scope for improvement of error messages that will report domain specific details for disallowed features,
201+
but it already prohibits them.
194202

195203
## Addendum: Default methods ##
196204
By `default methods` we mean non-abstract methods defined and implemented by a trait.

0 commit comments

Comments
 (0)