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 @@ -185,16 +185,22 @@ usesDefaultDefinition(AssociatedTypeDecl *requirement) const {
185
185
bool ProtocolConformance::isRetroactive () const {
186
186
auto extensionModule = getDeclContext ()->getParentModule ();
187
187
auto protocolModule = getProtocol ()->getParentModule ();
188
- if (extensionModule->isSameModuleLookingThroughOverlays (protocolModule)) {
188
+
189
+ auto isSameRetroactiveContext =
190
+ [](ModuleDecl *moduleA, ModuleDecl *moduleB) -> bool {
191
+ return moduleA->isSameModuleLookingThroughOverlays (moduleB)) ||
192
+ moduleA->inSamePackage (moduleB));
193
+ };
194
+
195
+ if (isSameRetroactiveContext (extensionModule, protocolModule)) {
189
196
return false ;
190
197
}
191
198
192
199
auto conformingTypeDecl =
193
200
ConformingType->getNominalOrBoundGenericNominal ();
194
201
if (conformingTypeDecl) {
195
202
auto conformingTypeModule = conformingTypeDecl->getParentModule ();
196
- if (extensionModule->
197
- isSameModuleLookingThroughOverlays (conformingTypeModule)) {
203
+ if (isSameRetroactiveContext (extensionModule, conformingTypeModule)) {
198
204
return false ;
199
205
}
200
206
}
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