-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[AutoDiff upstream] forbid @derivative of protocol req #29031
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
Conversation
@@ -185,6 +185,11 @@ protocol StaticMethod: Differentiable { | |||
static func generic<T: Differentiable>(_ x: T) -> T | |||
} | |||
|
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 feel we need an error message stating clearly that defining derivatives for protocol requirements is not yet supported.
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.
Customized diagnostics may require extra support in findAbstractFunctionDecl
in TypeCheckAttr.cpp
. Currently, when std::function<bool(AbstractFunctionDecl *)> &isValidCandidate
returns false
for all candidates, a single generic error is emitted (std::function<void()> &noneValidDiagnostic
).
We could change isValidCandidate
emit diagnostics as a side effect, but this requires clever diagnostic cancellation (via DiagnosticTransaction
) in case a valid candidate is found.
Alternatively, we could keep track of all invalid candidates and change noneValidDiagnostic
to std::function<void(AbstractFunctionDecl *)> ¬ValidDiagnostic
, so customized diagnostics can be emitted for every invalid candidate.
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 seems like more work than it's worth, especially since it's a temporary limitation, so I won't do this in this PR.
7561235
to
d69e892
Compare
@swift-ci please test and merge |
@swift-ci Please test |
Build failed |
Build failed |
Forbids @derivatives of protocol requirements, because they do not do anything until TF-982 is implemented.
This is the master branch version of #28890.