Skip to content

Commit e6976e6

Browse files
committed
Sema: Centralize exportability reason spelling
1 parent e04f4ea commit e6976e6

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3840,14 +3840,17 @@ NOTE(enum_raw_value_incrementing_from_zero,none,
38403840
NOTE(construct_raw_representable_from_unwrapped_value,none,
38413841
"construct %0 from unwrapped %1 value", (Type, Type))
38423842

3843+
#define EXPORTABILITY_REASON_SELECT "select{" \
3844+
"here|as property wrapper here|" \
3845+
"as result builder here|" \
3846+
"in an extension with public or '@usableFromInline' members|" \
3847+
"in an extension with conditional conformances|" \
3848+
"in a public or '@usableFromInline' conformance|" \
3849+
"in an '@available' attribute here|" \
3850+
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}"
3851+
38433852
ERROR(decl_from_hidden_module,none,
3844-
"cannot use %kind0 %select{here|as property wrapper here|"
3845-
"as result builder here|"
3846-
"in an extension with public or '@usableFromInline' members|"
3847-
"in an extension with conditional conformances|"
3848-
"in a public or '@usableFromInline' conformance|"
3849-
"in an '@available' attribute here|"
3850-
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}1; "
3853+
"cannot use %kind0 %" EXPORTABILITY_REASON_SELECT "1; "
38513854
"%select{%2 has been imported as implementation-only|"
38523855
"it is an SPI imported from %2|"
38533856
"it is SPI|"
@@ -3859,14 +3862,7 @@ ERROR(decl_from_hidden_module,none,
38593862
"%0 is marked '@_implementationOnly'}3",
38603863
(const Decl *, unsigned, Identifier, unsigned))
38613864
ERROR(typealias_desugars_to_type_from_hidden_module,none,
3862-
"%0 aliases '%1.%2' and cannot be used %select{here|"
3863-
"as property wrapper here|"
3864-
"as result builder here|"
3865-
"in an extension with public or '@usableFromInline' members|"
3866-
"in an extension with conditional conformance|"
3867-
"in a public or '@usableFromInline' conformance|"
3868-
"<<ERROR>>|"
3869-
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}3 "
3865+
"%0 aliases '%1.%2' and cannot be used %" EXPORTABILITY_REASON_SELECT "3 "
38703866
"because %select{%4 has been imported as implementation-only|"
38713867
"it is an SPI imported from %4|"
38723868
"<<ERROR>>|"
@@ -3878,12 +3874,7 @@ ERROR(typealias_desugars_to_type_from_hidden_module,none,
38783874
"%0 is marked '@_implementationOnly'}5",
38793875
(const TypeAliasDecl *, StringRef, StringRef, unsigned, Identifier, unsigned))
38803876
ERROR(conformance_from_implementation_only_module,none,
3881-
"cannot use conformance of %0 to %1 %select{here|as property wrapper here|"
3882-
"as result builder here|"
3883-
"in an extension with public or '@usableFromInline' members|"
3884-
"in an extension with conditional conformances|"
3885-
"<<ERROR>>|<<ERROR>>|"
3886-
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}2; "
3877+
"cannot use conformance of %0 to %1 %" EXPORTABILITY_REASON_SELECT "2; "
38873878
"%select{%3 has been imported as implementation-only|"
38883879
"the conformance is declared as SPI in %3|"
38893880
"the conformance is declared as SPI|"

lib/Sema/TypeCheckAvailability.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ enum class DeclAvailabilityFlag : uint8_t {
7070
};
7171
using DeclAvailabilityFlags = OptionSet<DeclAvailabilityFlag>;
7272

73-
// This enum must be kept in sync with
74-
// diag::decl_from_hidden_module,
75-
// diag::typealias_desugars_to_type_from_hidden_module, and
76-
// diag::conformance_from_implementation_only_module.
73+
// Classification of the kind of declaration visible to clients that is
74+
// restricting references to some decls.
75+
//
76+
// This enum must be kept in sync with diag's `EXPORTABILITY_REASON_SELECT`,
77+
// and fit in the size of `ExportContext.Reason`.
7778
enum class ExportabilityReason : unsigned {
7879
General,
7980
PropertyWrapper,
@@ -83,6 +84,7 @@ enum class ExportabilityReason : unsigned {
8384
Inheritance,
8485
AvailableAttribute,
8586
PublicVarDecl,
87+
ImplicitlyPublicVarDecl,
8688
};
8789

8890
/// A description of the restrictions on what declarations can be referenced

0 commit comments

Comments
 (0)