-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Refine access note descriptions in diagnostics #36865
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
18a35a9
to
e89b862
Compare
cd2c859
to
60b2836
Compare
@swift-ci please test |
Build failed |
Build failed |
60b2836
to
ccf86c4
Compare
@swift-ci please test |
Build failed |
Build failed |
/// diagnostic currently in \c *this. | ||
/// \li The location, ranges, decl, fix-its, and behavior limit of the | ||
/// diagnostic currently in \c *this. | ||
InFlightDiagnostic &wrapIn(const Diagnostic &wrapper); |
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.
Can you tell me more about the advantage of wrapping this diagnostic in the Xcode display? Should we apply the same trick to more kind of diagnostics or is this specific to access notes?
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.
Basically, Xcode's inline error UI doesn't display notes unless they have fix-its. Wrapping a diagnostic produces a longer message, but it's a single message that will actually be made visible to users in the UI they most often use to read diagnostics.
I've been thinking that it might be good to turn diag::module_interface_build_failed
and friends into wrapping diagnostics around the underlying errors, since the underlying errors often seem to go unnoticed by users, but are usually a better way to resolve the problem. But that's a different pull request.
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 looks good! I'll be curious to see a demo of it with all of the new diagnostics refinements.
Merge together several helpers and code patterns for “diagnose/fix-it/invalidate bad attribute” into helper functions in TypeChecker.h. This requires minor test changes in some places where we’re testing ObjC interop without importing Foundation; it’s otherwise NFC.
This requires deferring emission until the end of typechecking. A future change will emit access-note-related notes when an attribute is invalidated.
This shows up better in Xcode, which unfortunately doesn’t really display notes very clearly.
ccf86c4
to
5cd34ee
Compare
@swift-ci please test |
Build failed |
This will allow teams writing access notes to use -Raccess-note=all-validate to check that their access notes are correct, or teams working around problems to use -Raccess-note=failures or -Raccess-note=none to suppress diagnostics.
• There is now one access note success remark and fix-it per declaration, not per attribute/modifier. • Failure remarks have been rephrased to better emphasize the cause of the failure. • The wording of other access note remarks and notes have been changed to follow a similar formula.
When two members have the same ObjC selector, there’s a test used to make sure that we’re “giving” the selector to the more “authoritative” of the two. However, its logic is not symmetrical, which I suspect could cause misbehavior in some edge cases. This change formalizes the logic in a way that eliminates the asymmetry.
@swift-ci smoke test and merge |
5cd34ee
to
d4cae43
Compare
@swift-ci smoke test and merge |
This PR will finalize the way diagnostics describe when they're caused by access notes.
Specifically, the pre-existing access note remarks are now only emitted for valid attributes; for invalid attributes, the diagnostic is augmented with text explaining that it was added for an access note and has been disabled:
To accomplish this behavior, this PR makes it possible for a diagnostic to take a
DiagnosticInfo *
as a parameter; it then adds anInFlightDiagnostic::wrapIn()
method which uses this capability. Thus, an error likediag::objc_invalid_on_func_single_param_type
can be wrapped indiag::wrap_invalid_attr_added_by_access_note
to add verbiage relating to access notes.This PR also:
I will probably be tweaking this further before I'm finished with this PR.Fixes rdar://71872575.