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 {
27832783 bool forConformance = false ,
27842784 bool allowUsableFromInline = false ) const ;
27852785
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+
27862796 // / Returns whether this declaration should be treated as \c open from
27872797 // / \p useDC. This is very similar to #getFormalAccess, but takes
27882798 // / \c \@testable into account.
Original file line number Diff line number Diff line change @@ -4326,6 +4326,16 @@ bool ValueDecl::isAccessibleFrom(const DeclContext *useDC,
43264326 [&]() { return getFormalAccess (); });
43274327}
43284328
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+
43294339bool AbstractStorageDecl::isSetterAccessibleFrom (const DeclContext *DC,
43304340 bool forConformance) const {
43314341 assert (isSettable (DC));
You can’t perform that action at this time.
0 commit comments