File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -2783,6 +2783,16 @@ class ValueDecl : public Decl {
2783
2783
bool forConformance = false ,
2784
2784
bool allowUsableFromInline = false ) const ;
2785
2785
2786
+ using ImportAccessLevel = llvm::Optional<AttributedImport<ImportedModule>>;
2787
+
2788
+ // / Returns the import that may restrict the access to this decl
2789
+ // / from \p useDC.
2790
+ // /
2791
+ // / If this decl and \p useDC are from the same module it returns
2792
+ // / \c llvm::None. If there are many imports, it returns the most
2793
+ // / permissive one.
2794
+ ImportAccessLevel getImportAccessFrom (const DeclContext *useDC) const ;
2795
+
2786
2796
// / Returns whether this declaration should be treated as \c open from
2787
2797
// / \p useDC. This is very similar to #getFormalAccess, but takes
2788
2798
// / \c \@testable into account.
Original file line number Diff line number Diff line change @@ -4326,6 +4326,16 @@ bool ValueDecl::isAccessibleFrom(const DeclContext *useDC,
4326
4326
[&]() { return getFormalAccess (); });
4327
4327
}
4328
4328
4329
+ ImportAccessLevel ValueDecl::getImportAccessFrom (const DeclContext *useDC) const {
4330
+ ModuleDecl *Mod = getModuleContext ();
4331
+ if (useDC && useDC->getParentModule () != Mod) {
4332
+ if (auto useSF = useDC->getParentSourceFile ()) {
4333
+ return useSF->getImportAccessLevel (Mod);
4334
+ }
4335
+ }
4336
+ return llvm::None;
4337
+ }
4338
+
4329
4339
bool AbstractStorageDecl::isSetterAccessibleFrom (const DeclContext *DC,
4330
4340
bool forConformance) const {
4331
4341
assert (isSettable (DC));
You can’t perform that action at this time.
0 commit comments