Skip to content

Commit aa836e1

Browse files
committed
[CSOptimizer] MemberImportVisibility: Don't consider overloads that come from implicit imports
Ignore declarations that come from implicitly imported modules when `MemberImportVisibility` feature is enabled otherwise we might end up favoring an overload that would be diagnosed as unavailable later. Resolves: rdar://143582881
1 parent e8fe5c3 commit aa836e1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

lib/Sema/CSOptimizer.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ void forEachDisjunctionChoice(
175175
if (!decl)
176176
continue;
177177

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+
178190
// If disjunction choice is unavailable or disfavored we cannot
179191
// do anything with it.
180192
if (decl->getAttrs().hasAttribute<DisfavoredOverloadAttr>() ||
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -typecheck %t/Main.swift %t/Other.swift -enable-upcoming-feature MemberImportVisibility
5+
6+
//--- Main.swift
7+
8+
import Foundation
9+
10+
func test() -> CGSize {
11+
return CGSize(width: 60, height: 45)
12+
}
13+
14+
//--- Other.swift
15+
16+
import CoreGraphics

0 commit comments

Comments
 (0)