Skip to content

Commit 8ce5c77

Browse files
authored
Merge pull request swiftlang#30232 from xedin/rdar-60047439
[ConstraintSystem] Check availability as part of resolving overload c…
2 parents 86748ae + 4c60084 commit 8ce5c77

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,9 +2292,6 @@ Constraint *ConstraintSystem::selectDisjunction() {
22922292
}
22932293

22942294
bool DisjunctionChoice::attempt(ConstraintSystem &cs) const {
2295-
if (isUnavailable())
2296-
cs.increaseScore(SK_Unavailable);
2297-
22982295
cs.simplifyDisjunctionChoice(Choice);
22992296

23002297
if (ExplicitConversion)

lib/Sema/ConstraintSystem.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,6 +1885,10 @@ isInvalidPartialApplication(ConstraintSystem &cs,
18851885
std::pair<Type, bool> ConstraintSystem::adjustTypeOfOverloadReference(
18861886
const OverloadChoice &choice, ConstraintLocator *locator,
18871887
Type boundType, Type refType) {
1888+
// If the declaration is unavailable, note that in the score.
1889+
if (isDeclUnavailable(choice.getDecl(), locator))
1890+
increaseScore(SK_Unavailable);
1891+
18881892
bool bindConstraintCreated = false;
18891893
const auto kind = choice.getKind();
18901894
if (kind != OverloadChoiceKind::DeclViaDynamic &&

test/Constraints/availability.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,22 @@ class C : P {
1515
func f(c: C) {
1616
let _: C? = C(c)
1717
}
18+
19+
// rdar://problem/60047439 - unable to disambiguite expression based on availablity
20+
func test_contextual_member_with_availability() {
21+
struct A {
22+
static var foo: A = A()
23+
}
24+
25+
struct B {
26+
@available(*, unavailable, renamed: "bar")
27+
static var foo: B = B()
28+
}
29+
30+
struct Test {
31+
init(_: A) {}
32+
init(_: B) {}
33+
}
34+
35+
_ = Test(.foo) // Ok
36+
}

0 commit comments

Comments
 (0)