Comments (4)
It's something I deliberately decided not to do, but why not.
from binary-compatibility-validator.
For declarations having different targets, we'll continue ranking more common declarations (i.e. having a broader targets set) higher.
For declarations having the same set of declarations we can:
- on the top level:
- print interfaces, classes and objects first
- then properties
- then functions
- in the nested scope (i.e. within a class):
- print properties first
- then constructors
- then all other functions
- then interfaces, classes and objects
- then enum entries
Not sure if we need to rank declarations within the same "group" using declaration type/modality/some other attribute, for instance, by placing annotations before interfaces, placing vals before vars, or ranking final classifiers above open ones.
from binary-compatibility-validator.
For declarations having different targets, we'll continue ranking more common declarations (i.e. having a broader targets set) higher.
Does this mean that adding support for more targets to an existing declaration moves the location of a function in the file? From the perspective of reviewing a diff (since the tool currently does not do compatibility validation), having the signature remain in a fixed location seems more important. This way you can easily ensure the signature has not changed, only the targets. If the signature jumps tens or hundreds of lines in the file then I have to be very careful to ensure both match.
Of course such a thing is completely a non-issue if the tool switches to perform compatibility validation itself.
For declarations having the same set of declarations we can:
* on the top level: * print interfaces, classes and objects first * then properties * then functions * in the nested scope (i.e. within a class): * print properties first * then constructors * then all other functions * then interfaces, classes and objects * then enum entries
Any fixed order is fine, of course.
If you want me to bikeshed this, though, I would choose
- Enum entries
- Constructors
- Properties
- Functions
- Nested types
Constructors are most important everywhere except enums where entries are the most important. Then it's properties and functions. Then nested types.
Not sure if we need to rank declarations within the same "group" using declaration type/modality/some other attribute, for instance, by placing annotations before interfaces, placing vals before vars, or ranking final classifiers above open ones.
I wouldn't choose any sorting key that could be changed while still retaining compatibility. For example, val to var is a compatible migration, but I wouldn't want such a change to move the signature in the file causing a noisy diff. Similarly, final to open is a compatible change and I wouldn't want it to move as a result.
Changing class to interface is not compatible, so having them be separate isn't a huge deal. They would only jump for incompatible changes. Now unfortunately class to object and object to class can both be done compatibly, so perhaps they should be considered the same.
from binary-compatibility-validator.
Does this mean that adding support for more targets to an existing declaration moves the location of a function in the file?
It does, yes.
To avoid that issue, we should not be consider targets when sorting declarations. That would result in declarations belonging to different targets being interleaved. Then, it might be harder to grasp actual targets set for top-level declarations available for all targets (as these declarations without // Targets
may be surrounded with declarations having their // Targets
).
I would expect that for a regular library declarations should not change their targets too often to annoy reviewers.
On the other hand, grouping by targets gives a dump more structure.
Constructors are most important everywhere except enums where entries are the most important. Then its properties and functions. Then nested types.
Makes perfect sense, thanks.
For example, val to var is a compatible migration
As a side note, it is currently considered incompatible for klibs. :'(
Motivating issue: https://youtrack.jetbrains.com/issue/KT-44605
from binary-compatibility-validator.
Related Issues (20)
- org.gradle.api.InvalidUserDataException? HOT 2
- @JvmOverloads doesn't generate different methods for compose functions HOT 2
- Klib validation DSL for Groovy is different HOT 1
- Removal of default parameter is binary compatible but breaks runtime HOT 3
- `public` members of non-API supertype should be visible in the inheritor
- Unknown native target errors with Kotlin 2.0.0-RC1 HOT 4
- `KlibSignatureVersion.LATEST.toString()` is rendered as `KlibSignatureVersion(-2147483648)`
- Add Gradle version compatibility tests HOT 2
- Consider moving BCV to Kotlin repo HOT 3
- Description of a Syncs API task is uninformative HOT 1
- Add brief description to the top of .api dumps, to help explain the file and BCV
- Remove case-insensitive dump file names handling logic HOT 16
- Merge JVM and KLib ABI dumps into a single file
- Use a project/module-agnostic name for dump files
- Removing native targets did not cause API check to fail HOT 4
- Support Multi-Release JAR Files HOT 9
- allow apiDumpDirectory outside projectDir if inside rootProjectDir
- Allow `apiCheck` to run on all subprojects before failing HOT 2
- Migrate to newer kotlin-metadata-jvm HOT 9
- BCV behavior for an empty module is inconsistent between JVM and KMP
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binary-compatibility-validator.