-
Notifications
You must be signed in to change notification settings - Fork 1k
@stableABI
SIP.
#654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@stableABI
SIP.
#654
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ disqus: true | |
|
||
__Dmitry Petrashko__ | ||
|
||
__first submitted 13 February 2017__ | ||
__first submitted 13 January 2017__ | ||
|
||
## Introduction ## | ||
|
||
|
@@ -19,7 +19,15 @@ As long as signatures of methods in source is not changed, `@binaryCompatible` a | |
will be compatible across major version of Scala. | ||
|
||
## Use Cases | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. < 10000 /p> Can we number these use cases, i.e. have this section look as follows:
|
||
Dotty currently uses java defined interfaces as public API for SBT in order to ensure binary compatibility. | ||
In case there's a need to develop an API that will be used by clients compiled using different major versions of Scala, | ||
the current approach is to either develop them in Java or to use best guess to restrict what Scala features should be used. | ||
There's also a different approach which is used by SBT: instead of publishing a binary `compiler-interface`, sources are published instead | ||
that would be locally compiled. | ||
|
||
There's also a use-case of defining a class which is supposed to be also used from Java. | ||
`@binaryCompatible` will ensure that there are no not-expected methods that would show up in members of a class or an interface. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/not-expected/unexpected/ |
||
|
||
Dotty currently uses java defined interfaces as public API for IntelliJ in order to ensure binary compatibility. | ||
These interfaces can be replaced by `@binaryCompatible` annotated traits to reach the same goal. | ||
|
||
## Design Guidelines | ||
|
@@ -55,7 +63,6 @@ trait AbstractFile { | |
|
||
@binaryCompatible | ||
trait SourceFile extends AbstractFile { | ||
/** @return The content of this file as seen by the compiler. */ | ||
def content(): Array[Char] | ||
} | ||
|
||
|
@@ -75,13 +82,22 @@ object Diagnostic { | |
@static final val INFO: Int = 0 | ||
} | ||
|
||
@binaryCompatible | ||
class FeaturesInBodies { | ||
def apiMethod: Int = { | ||
// as body of the method isn't part of the public interface, one can use all features of Scala here. | ||
lazy val result = 0 // while lazy vals are prohibited in the class, they are allowed in the bodies of methods | ||
result | ||
} | ||
} | ||
{% endhighlight %} | ||
``` | ||
|
||
## Features that will fail compilation with `@binaryCompatible` | ||
The features listed below have complex encodings that may change in future versions. We prefer not to compromise on them. | ||
Most of those features can be simulated in a binary compatible way by writing a verbose re-impelemtation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo. |
||
which won't rely on desugaring performed inside compiler. | ||
Note that while those features are prohibited in the public API, they can be safely used inside bodies of the methods. | ||
|
||
- public fields. Can be simulated by explicitly defining public getters and setters that access a private field; | ||
- lazy vals. Can be simulated by explicitly writing an implementation in source; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this document would benefit from the definitions of the following terms:
I'd suggest having a small example that introduces and illustrates these notions.