-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add all interface's class-level annotations to its DefaultImpls class. #161
Add all interface's class-level annotations to its DefaultImpls class. #161
Conversation
27424fd
to
493ba62
Compare
/** | ||
* For synthetic $DefaultImpls classes copy annotations from the original interface | ||
*/ | ||
val inheritedAnnotations = mutableListOf<AnnotationNode>().apply { |
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.
Could you please check if it is possible to consolidate annotation "inheritance" in a single place?
AFAIR we have a multitude of such logic, some examples are:
PublishedApi
and methods with default arguments- Regular annotations (e.g.
@PrivateApi
) and methods with default arguments - Nested objects/companions and
@JvmStatic
- Companions and
INSTANCE
- Fields and accessors
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.
It seems like now there are only 3 cases when we're "inheriting" ("propagating" would fit better, I guess) annotations for an entity from some other entities:
- for fields, we're taking annotations from accessors (and with Add all Companion class' annotations to corresponding Companion field. #162 we'll propagate companion class' annotations to the corresponding field);
- for methods, we're taking annotations from other property accessors and fields and also from a regular method declaration if the current one is "$default";
- for classes, if a class is "$DefaultImpls", we're taking annotations from the "original" class.
Currently, the logic is local w.r.t. the entity's processing scope (i.e. we're collecting annotations for a field when processing a field, for a method when processing that method and so on) and I'm not sure if we could do significantly better.
There's always an option to rewrite all the processing logic to have a single object encompassing the whole context (instead of tossing parts of that context across various extension functions) and have (still) separate methods responsible for annotation extraction there, but I think it is out of this PR's scope.
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.
Thanks for taking a look!
…efaultImpls class. Fixes Kotlin/binary-compatibility-validator#155 Pull request Kotlin/binary-compatibility-validator#161
…efaultImpls class. Fixes Kotlin/binary-compatibility-validator#155 Pull request Kotlin/binary-compatibility-validator#161
…efaultImpls class. Fixes Kotlin/binary-compatibility-validator#155 Pull request Kotlin/binary-compatibility-validator#161
…efaultImpls class. Fixes Kotlin/binary-compatibility-validator#155 Pull request Kotlin/binary-compatibility-validator#161 Moved from Kotlin/binary-compatibility-validator@1d7505b
…efaultImpls class. Fixes Kotlin/binary-compatibility-validator#155 Pull request Kotlin/binary-compatibility-validator#161 Moved from Kotlin/binary-compatibility-validator@1d7505b
Fixes #155