@@ -584,14 +584,24 @@ struct AttributedImport {
584
584
// / attribute, this is the given access level.
585
585
Optional<AccessLevel> docVisibility;
586
586
587
+ // / Access level limiting how imported types can be exported.
588
+ AccessLevel accessLevel;
589
+
590
+ // / Location of the attribute that defined \c accessLevel. Also indicates
591
+ // / if the access level was implicit or explicit.
592
+ SourceLoc accessLevelLoc;
593
+
587
594
AttributedImport (ModuleInfo module , SourceLoc importLoc = SourceLoc(),
588
595
ImportOptions options = ImportOptions(),
589
596
StringRef filename = {}, ArrayRef<Identifier> spiGroups = {},
590
597
SourceRange preconcurrencyRange = {},
591
- Optional<AccessLevel> docVisibility = None)
598
+ Optional<AccessLevel> docVisibility = None,
599
+ AccessLevel accessLevel = AccessLevel::Public,
600
+ SourceLoc accessLevelLoc = SourceLoc())
592
601
: module (module ), importLoc(importLoc), options(options),
593
602
sourceFileArg (filename), spiGroups(spiGroups),
594
- preconcurrencyRange(preconcurrencyRange), docVisibility(docVisibility) {
603
+ preconcurrencyRange(preconcurrencyRange), docVisibility(docVisibility),
604
+ accessLevel(accessLevel), accessLevelLoc(accessLevelLoc) {
595
605
assert (!(options.contains (ImportFlags::Exported) &&
596
606
options.contains (ImportFlags::ImplementationOnly)) ||
597
607
options.contains (ImportFlags::Reserved));
@@ -601,15 +611,18 @@ struct AttributedImport {
601
611
AttributedImport (ModuleInfo module , AttributedImport<OtherModuleInfo> other)
602
612
: AttributedImport(module , other.importLoc, other.options,
603
613
other.sourceFileArg, other.spiGroups,
604
- other.preconcurrencyRange, other.docVisibility) { }
614
+ other.preconcurrencyRange, other.docVisibility,
615
+ other.accessLevel, other.accessLevelLoc) { }
605
616
606
617
friend bool operator ==(const AttributedImport<ModuleInfo> &lhs,
607
618
const AttributedImport<ModuleInfo> &rhs) {
608
619
return lhs.module == rhs.module &&
609
620
lhs.options .toRaw () == rhs.options .toRaw () &&
610
621
lhs.sourceFileArg == rhs.sourceFileArg &&
611
622
lhs.spiGroups == rhs.spiGroups &&
612
- lhs.docVisibility == rhs.docVisibility ;
623
+ lhs.docVisibility == rhs.docVisibility &&
624
+ lhs.accessLevel == rhs.accessLevel &&
625
+ lhs.accessLevelLoc == rhs.accessLevelLoc ;
613
626
}
614
627
615
628
AttributedImport<ImportedModule> getLoaded (ModuleDecl *loadedModule) const {
@@ -761,14 +774,16 @@ struct DenseMapInfo<swift::AttributedImport<ModuleInfo>> {
761
774
SourceLocDMI::getEmptyKey (),
762
775
ImportOptionsDMI::getEmptyKey (),
763
776
StringRefDMI::getEmptyKey (),
764
- {}, {}, None);
777
+ {}, {}, None,
778
+ swift::AccessLevel::Public, {});
765
779
}
766
780
static inline AttributedImport getTombstoneKey () {
767
781
return AttributedImport (ModuleInfoDMI::getTombstoneKey (),
768
782
SourceLocDMI::getEmptyKey (),
769
783
ImportOptionsDMI::getTombstoneKey (),
770
784
StringRefDMI::getTombstoneKey (),
771
- {}, {}, None);
785
+ {}, {}, None,
786
+ swift::AccessLevel::Public, {});
772
787
}
773
788
static inline unsigned getHashValue (const AttributedImport &import ) {
774
789
return detail::combineHashValue (
@@ -783,7 +798,9 @@ struct DenseMapInfo<swift::AttributedImport<ModuleInfo>> {
783
798
ImportOptionsDMI::isEqual (a.options , b.options ) &&
784
799
StringRefDMI::isEqual (a.sourceFileArg , b.sourceFileArg ) &&
785
800
a.spiGroups == b.spiGroups &&
786
- a.docVisibility == b.docVisibility ;
801
+ a.docVisibility == b.docVisibility &&
802
+ a.accessLevel == b.accessLevel &&
803
+ a.accessLevelLoc == b.accessLevelLoc ;
787
804
}
788
805
};
789
806
}
0 commit comments