Sema: Centralize exportability reason spelling

This commit is contained in:
Alexis Laferrière
2025-12-03 14:58:27 -08:00
parent e04f4eadf3
commit e6976e6291
2 changed files with 18 additions and 25 deletions

View File

@@ -3840,14 +3840,17 @@ NOTE(enum_raw_value_incrementing_from_zero,none,
NOTE(construct_raw_representable_from_unwrapped_value,none,
"construct %0 from unwrapped %1 value", (Type, Type))
#define EXPORTABILITY_REASON_SELECT "select{" \
"here|as property wrapper here|" \
"as result builder here|" \
"in an extension with public or '@usableFromInline' members|" \
"in an extension with conditional conformances|" \
"in a public or '@usableFromInline' conformance|" \
"in an '@available' attribute here|" \
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}"
ERROR(decl_from_hidden_module,none,
"cannot use %kind0 %select{here|as property wrapper here|"
"as result builder here|"
"in an extension with public or '@usableFromInline' members|"
"in an extension with conditional conformances|"
"in a public or '@usableFromInline' conformance|"
"in an '@available' attribute here|"
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}1; "
"cannot use %kind0 %" EXPORTABILITY_REASON_SELECT "1; "
"%select{%2 has been imported as implementation-only|"
"it is an SPI imported from %2|"
"it is SPI|"
@@ -3859,14 +3862,7 @@ ERROR(decl_from_hidden_module,none,
"%0 is marked '@_implementationOnly'}3",
(const Decl *, unsigned, Identifier, unsigned))
ERROR(typealias_desugars_to_type_from_hidden_module,none,
"%0 aliases '%1.%2' and cannot be used %select{here|"
"as property wrapper here|"
"as result builder here|"
"in an extension with public or '@usableFromInline' members|"
"in an extension with conditional conformance|"
"in a public or '@usableFromInline' conformance|"
"<<ERROR>>|"
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}3 "
"%0 aliases '%1.%2' and cannot be used %" EXPORTABILITY_REASON_SELECT "3 "
"because %select{%4 has been imported as implementation-only|"
"it is an SPI imported from %4|"
"<<ERROR>>|"
@@ -3878,12 +3874,7 @@ ERROR(typealias_desugars_to_type_from_hidden_module,none,
"%0 is marked '@_implementationOnly'}5",
(const TypeAliasDecl *, StringRef, StringRef, unsigned, Identifier, unsigned))
ERROR(conformance_from_implementation_only_module,none,
"cannot use conformance of %0 to %1 %select{here|as property wrapper here|"
"as result builder here|"
"in an extension with public or '@usableFromInline' members|"
"in an extension with conditional conformances|"
"<<ERROR>>|<<ERROR>>|"
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}2; "
"cannot use conformance of %0 to %1 %" EXPORTABILITY_REASON_SELECT "2; "
"%select{%3 has been imported as implementation-only|"
"the conformance is declared as SPI in %3|"
"the conformance is declared as SPI|"

View File

@@ -70,10 +70,11 @@ enum class DeclAvailabilityFlag : uint8_t {
};
using DeclAvailabilityFlags = OptionSet<DeclAvailabilityFlag>;
// This enum must be kept in sync with
// diag::decl_from_hidden_module,
// diag::typealias_desugars_to_type_from_hidden_module, and
// diag::conformance_from_implementation_only_module.
// Classification of the kind of declaration visible to clients that is
// restricting references to some decls.
//
// This enum must be kept in sync with diag's `EXPORTABILITY_REASON_SELECT`,
// and fit in the size of `ExportContext.Reason`.
enum class ExportabilityReason : unsigned {
General,
PropertyWrapper,
@@ -83,6 +84,7 @@ enum class ExportabilityReason : unsigned {
Inheritance,
AvailableAttribute,
PublicVarDecl,
ImplicitlyPublicVarDecl,
};
/// A description of the restrictions on what declarations can be referenced