Skip to content

Commit a9b0a66

Browse files
committed
Implementation-only import checking for types used in decls
Based on the existing access checker for types used in decls. There's a common skeleton here but we can't seem to get it out, so for now add a third DeclVisitor to this file. On the plus side, checking this alongside access is an easy way to make sure everything gets checked. Part of rdar://problem/48991061
1 parent 0f0ae58 commit a9b0a66

File tree

7 files changed

+525
-21
lines changed

7 files changed

+525
-21
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,11 @@ NOTE(enum_raw_value_incrementing_from_zero,none,
23922392
NOTE(construct_raw_representable_from_unwrapped_value,none,
23932393
"construct %0 from unwrapped %1 value", (Type, Type))
23942394

2395+
ERROR(decl_from_implementation_only_module,none,
2396+
"cannot use %0 here; %1 has been imported as "
2397+
"'@_implementationOnly'",
2398+
(DeclName, Identifier))
2399+
23952400
// Derived conformances
23962401
ERROR(cannot_synthesize_init_in_extension_of_nonfinal,none,
23972402
"implementation of %0 for non-final class cannot be automatically "

lib/AST/AccessScopeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ AccessScopeChecker::AccessScopeChecker(const DeclContext *useDC,
2828

2929
bool
3030
AccessScopeChecker::visitDecl(const ValueDecl *VD) {
31-
if (!VD || isa<GenericTypeParamDecl>(VD))
31+
if (isa<GenericTypeParamDecl>(VD))
3232
return true;
3333

3434
auto AS = VD->getFormalAccessScope(File, TreatUsableFromInlineAsPublic);

0 commit comments

Comments
 (0)