Improve checking of macro-generated accessors against documented names

The checking of the accessors generated by a macro against the
documented set of accessors for the macro is slightly too strict and
produces misleading error messages. Make the check slightly looser in
the case where an observer-producing macro (such as
`@ObservationIgnored`) is applied to a computed property. Here, we
would diagnose that the observer did not in fact produce any
observers, even though it couldn't have: computed properties don't get
observers. Remove the diagnostic in this case.

While here, add some tests and improve the wording of diagnostics a
bit.

Fixes rdar://113710199.
This commit is contained in:
Doug Gregor
2023-08-17 16:59:42 -07:00
parent b7bfaf3522
commit 5d6746d974
6 changed files with 110 additions and 23 deletions

View File

@@ -7228,10 +7228,13 @@ ERROR(invalid_macro_role_for_macro_syntax,none,
(unsigned))
ERROR(macro_cannot_introduce_names,none,
"'%0' macros are not allowed to introduce names", (StringRef))
ERROR(macro_accessor_missing_from_expansion,none,
"expansion of macro %0 did not produce a %select{non-|}1observing "
"accessor",
(DeclName, bool))
ERROR(macro_nonobserving_accessor_missing_from_expansion,none,
"expansion of macro %0 did not produce a non-observing accessor "
"(such as 'get') as expected",
(DeclName))
ERROR(macro_nonobserver_unexpected_in_expansion,none,
"expansion of macro %0 produced an unexpected %1",
(DeclName, DescriptiveDeclKind))
ERROR(macro_init_accessor_not_documented,none,
"expansion of macro %0 produced an unexpected 'init' accessor",
(DeclName))