File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -184,16 +184,22 @@ usesDefaultDefinition(AssociatedTypeDecl *requirement) const {
184
184
bool ProtocolConformance::isRetroactive () const {
185
185
auto extensionModule = getDeclContext ()->getParentModule ();
186
186
auto protocolModule = getProtocol ()->getParentModule ();
187
- if (extensionModule->isSameModuleLookingThroughOverlays (protocolModule)) {
187
+
188
+ auto isSameRetroactiveContext =
189
+ [](ModuleDecl *moduleA, ModuleDecl *moduleB) -> bool {
190
+ return moduleA->isSameModuleLookingThroughOverlays (moduleB)) ||
191
+ moduleA->inSamePackage (moduleB));
192
+ };
193
+
194
+ if (isSameRetroactiveContext (extensionModule, protocolModule)) {
188
195
return false ;
189
196
}
190
197
191
198
auto conformingTypeDecl =
192
199
ConformingType->getNominalOrBoundGenericNominal ();
193
200
if (conformingTypeDecl) {
194
201
auto conformingTypeModule = conformingTypeDecl->getParentModule ();
195
- if (extensionModule->
196
- isSameModuleLookingThroughOverlays (conformingTypeModule)) {
202
+ if (isSameRetroactiveContext (extensionModule, conformingTypeModule)) {
197
203
return false ;
198
204
}
199
205
}
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: split-file %s %t
3
+ // RUN: %target-swift-frontend -swift-version 5 %t/OtherLibrary.swift -package-name Library -emit-module -module-name OtherLibrary -package-name Library -o %t
4
+ // RUN: %target-swift-frontend -typecheck %t/Library.swift -module-name Library -package-name Library -verify -swift-version 5 -import-underlying-module -I %t
5
+ // RUN: %target-swift-frontend -typecheck %t/Client.swift -module-name Client -package-name Library -verify -swift-version 5 -I %t
6
+
7
+ //--- Library.swift
8
+
9
+ public class LibraryClass {
10
+ }
11
+
12
+ public protocol LibraryProtocol {
13
+ }
14
+
15
+ //--- OtherLibrary.swift
16
+ public class OtherLibraryClass { }
17
+ public class OtherLibraryProtocol { }
18
+
19
+ //--- Client.swift
20
+
21
+ import Library
22
+ import OtherLibrary
23
+
24
+ // These are all fine because all 3 of these libraries are in the same package.
25
+
26
+ extension LibraryClass : LibraryProtocol { }
27
+ extension OtherLibraryClass : LibraryProtocol { }
28
+ extension LibraryClass : OtherLibraryProtocol { }
You can’t perform that action at this time.
0 commit comments