Skip to content

Commit 8e04430

Browse files
committed
Sema: Differentiate the reason for implictly public memory layouts
1 parent e6976e6 commit 8e04430

File tree

5 files changed

+44
-34
lines changed

5 files changed

+44
-34
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3847,7 +3847,8 @@ NOTE(construct_raw_representable_from_unwrapped_value,none,
38473847
"in an extension with conditional conformances|" \
38483848
"in a public or '@usableFromInline' conformance|" \
38493849
"in an '@available' attribute here|" \
3850-
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context}"
3850+
"in a property declaration marked public or in a '@frozen' or '@usableFromInline' context|" \
3851+
"in a property declaration member of a type not marked '@_implementationOnly'}"
38513852

38523853
ERROR(decl_from_hidden_module,none,
38533854
"cannot use %kind0 %" EXPORTABILITY_REASON_SELECT "1; "

lib/Sema/ResilienceDiagnostics.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ static bool shouldDiagnoseDeclAccess(const ValueDecl *D,
261261
case ExportabilityReason::ResultBuilder:
262262
case ExportabilityReason::PropertyWrapper:
263263
case ExportabilityReason::PublicVarDecl:
264+
case ExportabilityReason::ImplicitlyPublicVarDecl:
264265
return false;
265266
}
266267
}

lib/Sema/TypeCheckAccess.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,8 +2383,12 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
23832383
if (seenVars.count(theVar))
23842384
return;
23852385

2386+
ExportabilityReason reason =
2387+
Where.getExportedLevel() == ExportedLevel::ImplicitlyExported ?
2388+
ExportabilityReason::ImplicitlyPublicVarDecl :
2389+
ExportabilityReason::PublicVarDecl;
23862390
checkType(theVar->getValueInterfaceType(), /*typeRepr*/nullptr, theVar,
2387-
ExportabilityReason::PublicVarDecl);
2391+
reason);
23882392

23892393
for (auto attr : theVar->getAttachedPropertyWrappers()) {
23902394
checkType(attr->getType(), attr->getTypeRepr(), theVar,
@@ -2405,9 +2409,13 @@ class DeclAvailabilityChecker : public DeclVisitor<DeclAvailabilityChecker> {
24052409
anyVar = V;
24062410
});
24072411

2412+
ExportabilityReason reason =
2413+
Where.getExportedLevel() == ExportedLevel::ImplicitlyExported ?
2414+
ExportabilityReason::ImplicitlyPublicVarDecl :
2415+
ExportabilityReason::PublicVarDecl;
24082416
checkType(TP->hasType() ? TP->getType() : Type(),
24092417
TP->getTypeRepr(), anyVar ? (Decl *)anyVar : (Decl *)PBD,
2410-
ExportabilityReason::PublicVarDecl);
2418+
reason);
24112419

24122420
// Check the property wrapper types.
24132421
if (anyVar) {

lib/Sema/TypeCheckAvailability.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class ExportContext {
120120
unsigned SPI : 1;
121121
unsigned Exported : 2;
122122
unsigned Implicit : 1;
123-
unsigned Reason : 3;
123+
unsigned Reason : 4;
124124

125125
ExportContext(DeclContext *DC, AvailabilityContext availability,
126126
FragileFunctionKind kind,

0 commit comments

Comments
 (0)