File tree 2 files changed +51
-0
lines changed
2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,18 @@ void forEachDisjunctionChoice(
175
175
if (!decl)
176
176
continue ;
177
177
178
+ // Ignore declarations that come from implicitly imported modules
179
+ // when `MemberImportVisibility` feature is enabled otherwise
180
+ // we might end up favoring an overload that would be diagnosed
181
+ // as unavailable later.
182
+ if (cs.getASTContext ().LangOpts .hasFeature (
183
+ Feature::MemberImportVisibility)) {
184
+ if (auto *useDC = constraint->getOverloadUseDC ()) {
185
+ if (!useDC->isDeclImported (decl))
186
+ continue ;
187
+ }
188
+ }
189
+
178
190
// If disjunction choice is unavailable or disfavored we cannot
179
191
// do anything with it.
180
192
if (decl->getAttrs ().hasAttribute <DisfavoredOverloadAttr>() ||
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %empty-directory(%t/src)
3
+ // RUN: split-file %s %t/src
4
+
5
+ /// Build the library A
6
+ // RUN: %target-swift-frontend -emit-module %t/src/A.swift \
7
+ // RUN: -module-name A \
8
+ // RUN: -emit-module-path %t/A.swiftmodule
9
+
10
+ /// Build the library B
11
+ // RUN: %target-swift-frontend -I %t -emit-module %t/src/B.swift \
12
+ // RUN: -module-name B \
13
+ // RUN: -emit-module-path %t/B.swiftmodule
14
+
15
+ // RUN: %target-swift-frontend -typecheck -I %t %t/src/Main.swift %t/src/Other.swift -enable-upcoming-feature MemberImportVisibility
16
+
17
+ // REQUIRES: swift_feature_MemberImportVisibility
18
+
19
+ //--- A.swift
20
+ public struct Test {
21
+ public init ( a: Double ) { }
22
+ }
23
+
24
+ //--- B.swift
25
+ import A
26
+
27
+ extension Test {
28
+ public init ( a: Int ) { fatalError ( ) }
29
+ }
30
+
31
+ //--- Main.swift
32
+ import A
33
+
34
+ func test( ) {
35
+ _ = Test ( a: 0 ) // Ok, selects the overload that takes Double.
36
+ }
37
+
38
+ //--- Other.swift
39
+ import B
You can’t perform that action at this time.
0 commit comments