Skip to content

Commit 75255d1

Browse files
committed
[Sema] Diagnose exportability of decls limited by a non-public import
Check the API of decls to ensure that imported types are only used in decls with compatible access-level. For example, error on using a type import as internal in a public function, but allow it in internal functions and lower. This change raises errors on wrongful use of types limited by an import and offers a note pointing to the import that did limit the imported type.
1 parent 40908e0 commit 75255d1

File tree

5 files changed

+1151
-95
lines changed

5 files changed

+1151
-95
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,9 @@ ERROR(access_level_on_import_unsupported, none,
20642064
ERROR(access_level_conflict_with_exported,none,
20652065
"'%0' is incompatible with %1; it can only be applied to public imports",
20662066
(DeclAttribute, DeclAttribute))
2067+
NOTE(module_imported_here,none,
2068+
"module %0 imported as '%select{private|fileprivate|internal|package|%ERROR|%ERROR}1' here",
2069+
(Identifier, AccessLevel))
20672070

20682071
// Opaque return types
20692072
ERROR(opaque_type_invalid_constraint,none,

0 commit comments

Comments
 (0)