File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -920,6 +920,9 @@ class alignas(1 << DeclAlignInBits) Decl {
920
920
// / If this returns true, the decl can be safely casted to ValueDecl.
921
921
bool isPotentiallyOverridable () const ;
922
922
923
+ // / Returns true if this Decl cannot be seen by any other source file
924
+ bool isPrivateToEnclosingFile () const ;
925
+
923
926
// / If an alternative module name is specified for this decl, e.g. using
924
927
// / @_originalDefinedIn attribute, this function returns this module name.
925
928
StringRef getAlternateModuleName () const ;
Original file line number Diff line number Diff line change @@ -8068,3 +8068,26 @@ void swift::simple_display(llvm::raw_ostream &out, AnyFunctionRef fn) {
8068
8068
else
8069
8069
out << " closure" ;
8070
8070
}
8071
+
8072
+ bool Decl::isPrivateToEnclosingFile () const {
8073
+ if (auto *VD = dyn_cast<ValueDecl>(this ))
8074
+ return VD->getFormalAccess () <= AccessLevel::FilePrivate;
8075
+ switch (getKind ()) {
8076
+ case DeclKind::Import:
8077
+ case DeclKind::PatternBinding:
8078
+ case DeclKind::EnumCase:
8079
+ case DeclKind::TopLevelCode:
8080
+ case DeclKind::IfConfig:
8081
+ case DeclKind::PoundDiagnostic:
8082
+ return true ;
8083
+
8084
+ case DeclKind::Extension:
8085
+ case DeclKind::InfixOperator:
8086
+ case DeclKind::PrefixOperator:
8087
+ case DeclKind::PostfixOperator:
8088
+ return false ;
8089
+
8090
+ default :
8091
+ llvm_unreachable (" everything else is a ValueDecl" );
8092
+ }
8093
+ }
You can’t perform that action at this time.
0 commit comments