-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Diagnose public protocol requirements witnessed by internal protocol extensions #85846
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
base: main
Are you sure you want to change the base?
Conversation
|
There is still work to be done here (since a draft PR). This change breaks 18 tests, most of them due to the warning that is generated. One approach is to introduce a new UPCOMING_FEATURE flag and hide the diagnose behind it. |
|
These fail due to the warning: These fail due to the error: |
lib/Sema/TypeCheckProtocol.cpp
Outdated
| if (!witness->isAccessibleFrom(actualScopeToCheck.getDeclContext())) { | ||
| if (dc->getParentModule()->isResilient()) { | ||
| // This module was built with -enable-library-evolution | ||
| dc->getASTContext().Diags.diagnose(witness->getLoc(), diag::err_private_member_witness_public_protocol, |
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.
witness->diagnose(...)
| return 42 | ||
| } | ||
| } | ||
|
|
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.
Too many blank lines
| protocol InternalProtocol: PublicProtocol {} | ||
|
|
||
| extension InternalProtocol { | ||
|
|
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.
Ditto
| ERROR(err_private_member_witness_public_protocol,none, | ||
| "%0 is private and should not witness public protocol %1", | ||
| (const ValueDecl *,const ProtocolDecl *)) | ||
| WARNING(warn_private_member_witness_public_protocol,none, |
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.
There's already a mechanism to emit something as a warning or error, with warnUntilFutureSwiftVersionIf()
8d1eebe to
48c1267
Compare
Private member witnessing a public constraint should be deprecated. If StrictSemaForTextualInterface is set, compiler emits a warning (in future versions -- an error) when access check is not passed. rdar://74904373
48c1267 to
3340009
Compare
Private member witnessing a public constraint should be deprecated. With this change compiler emits an error when access check is not passed in library evolution mode (emits a warning otherwise).
rdar://74904373