Skip to content

Commit 519fa00

Browse files
committed
Check signatures for conformances from implementation-only imports
These also create a dependency on the implementation module, even if both the type and the protocol are public. As John puts it, a conformance is basically a declaration that we name as part of another declaration. More rdar://problem/48991061
1 parent d88419d commit 519fa00

8 files changed

+200
-57
lines changed

include/swift/AST/AccessScopeChecker.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ class TypeDeclFinder : public TypeWalker {
5454
Action walkToTypePre(Type T) override;
5555

5656
public:
57-
virtual Action visitNominalType(const NominalType *ty) {
57+
virtual Action visitNominalType(NominalType *ty) {
5858
return Action::Continue;
5959
}
60-
virtual Action visitBoundGenericType(const BoundGenericType *ty) {
60+
virtual Action visitBoundGenericType(BoundGenericType *ty) {
6161
return Action::Continue;
6262
}
63-
virtual Action visitTypeAliasType(const TypeAliasType *ty) {
63+
virtual Action visitTypeAliasType(TypeAliasType *ty) {
6464
return Action::Continue;
6565
}
6666
};
@@ -72,9 +72,9 @@ class SimpleTypeDeclFinder : public TypeDeclFinder {
7272
/// The function to call when a ComponentIdentTypeRepr is seen.
7373
llvm::function_ref<Action(const TypeDecl *)> Callback;
7474

75-
Action visitNominalType(const NominalType *ty) override;
76-
Action visitBoundGenericType(const BoundGenericType *ty) override;
77-
Action visitTypeAliasType(const TypeAliasType *ty) override;
75+
Action visitNominalType(NominalType *ty) override;
76+
Action visitBoundGenericType(BoundGenericType *ty) override;
77+
Action visitTypeAliasType(TypeAliasType *ty) override;
7878

7979
public:
8080
explicit SimpleTypeDeclFinder(

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,10 @@ ERROR(decl_from_implementation_only_module,none,
23912391
"cannot use %0 here; %1 has been imported as "
23922392
"'@_implementationOnly'",
23932393
(DeclName, Identifier))
2394+
ERROR(conformance_from_implementation_only_module,none,
2395+
"cannot use conformance of %0 to %1 here; %2 has been imported as "
2396+
"'@_implementationOnly'",
2397+
(Type, DeclName, Identifier))
23942398

23952399
// Derived conformances
23962400
ERROR(cannot_synthesize_init_in_extension_of_nonfinal,none,

lib/AST/AccessScopeChecker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ TypeWalker::Action TypeDeclFinder::walkToTypePre(Type T) {
7171
}
7272

7373
TypeWalker::Action
74-
SimpleTypeDeclFinder::visitNominalType(const NominalType *ty) {
74+
SimpleTypeDeclFinder::visitNominalType(NominalType *ty) {
7575
return Callback(ty->getDecl());
7676
}
7777

7878
TypeWalker::Action
79-
SimpleTypeDeclFinder::visitBoundGenericType(const BoundGenericType *ty) {
79+
SimpleTypeDeclFinder::visitBoundGenericType(BoundGenericType *ty) {
8080
return Callback(ty->getDecl());
8181
}
8282

8383
TypeWalker::Action
84-
SimpleTypeDeclFinder::visitTypeAliasType(const TypeAliasType *ty) {
84+
SimpleTypeDeclFinder::visitTypeAliasType(TypeAliasType *ty) {
8585
return Callback(ty->getDecl());
8686
}
8787

0 commit comments

Comments
 (0)