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
[AutoDiff] Require same access level for original/derivative functions. #31527
[AutoDiff] Require same access level for original/derivative functions. #31527
Conversation
@swift-ci Please smoke test |
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.
This additional restriction will break users.
Well, this will break users by bringing possible linker errors to compile-time errors :)
Require `@derivative` functions and their original functions to have the same access level. Public original functions may also have internal `@usableFromInline` derivatives, as a special case. Diagnose access level mismatches. This simplifies derivative registration rules, and may enable simplification of AutoDiff symbol linkage rules. Resolves TF-1099 and TF-1160.
Use a single consistent error message stating "derivative function must have same access level as original function". Add access level fix-it on the derivative function.
a6bba14
to
7851a74
Compare
fe0987b
to
542eb4f
Compare
This is better than suggesting derivative access level change to public.
542eb4f
to
2a23bfc
Compare
@swift-ci Please test |
Build failed |
Build failed |
…s. (apple#31527) Require `@derivative` functions and their original functions to have the same access level. Public original functions may also have internal `@usableFromInline` derivatives, as a special case. Diagnose access level mismatches. Produce a fix-it to change the derivative function's access level. This simplifies derivative registration rules, and may enable simplification of AutoDiff symbol linkage rules. Resolves TF-1099 and TF-1160.
…s. (apple#31527) Require `@derivative` functions and their original functions to have the same access level. Public original functions may also have internal `@usableFromInline` derivatives, as a special case. Diagnose access level mismatches. Produce a fix-it to change the derivative function's access level. This simplifies derivative registration rules, and may enable simplification of AutoDiff symbol linkage rules. Resolves TF-1099 and TF-1160.
Require
@derivative
functions and their original functions to have the same access level.Public original functions may also have internal
@usableFromInline
derivatives, as a special case. Diagnose access level mismatches.This simplifies derivative registration rules, and may enable simplification of AutoDiff symbol linkage rules.
Resolves TF-1099 and TF-1160.
Example:
Future direction: anonymous
func
declarations (SR-12003) will enable public derivative functions without exposing them as public API.This additional restriction will break users. Fix all
@derivative
usage errors caught by "community CI" before merging.Done: tensorflow/swift-apis#929