Skip to content

Commit 5c8d64a

Browse files
authored
Merge pull request #36300 from xedin/overload-filter-for-members
[ConstraintSystem] Use correct locator when filtering disjunction cho…
2 parents 42e1952 + 2df4ba7 commit 5c8d64a

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9373,7 +9373,7 @@ bool ConstraintSystem::simplifyAppliedOverloads(
93739373
AppliedDisjunctions[disjunction->getLocator()] = argFnType;
93749374
return simplifyAppliedOverloadsImpl(disjunction, fnTypeVar, argFnType,
93759375
/*numOptionalUnwraps*/ result->second,
9376-
locator);
9376+
applicableFn->getLocator());
93779377
}
93789378

93799379
bool ConstraintSystem::simplifyAppliedOverloads(

test/Constraints/overload_filtering.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,25 @@ func testUnresolvedMember(i: Int) -> X {
3838
// CHECK-NEXT: introducing single enabled disjunction term {{.*}} bound to decl overload_filtering.(file).X.init(_:_:)
3939
return .init(i, i)
4040
}
41+
42+
func test_member_filtering() {
43+
struct S {
44+
// Result types here are different intentionally,
45+
// if there were the same simplication logic would
46+
// trigger and disable overloads during constraint
47+
// generation.
48+
func foo(_: Int) -> S { S() }
49+
func foo(_: String) -> Int { 42 }
50+
51+
func bar(v: String) {}
52+
func bar(_: Int) {}
53+
func bar(a: Double, b: Int) {}
54+
}
55+
56+
func test(s: S) {
57+
// CHECK: disabled disjunction term {{.*}} bound to decl overload_filtering.(file).test_member_filtering().S.bar(v:)
58+
// CHECK-NEXT: disabled disjunction term {{.*}} bound to decl overload_filtering.(file).test_member_filtering().S.bar(a:b:)
59+
// CHECK-NEXT: introducing single enabled disjunction term {{.*}} bound to decl overload_filtering.(file).test_member_filtering().S.bar
60+
s.foo(42).bar(42)
61+
}
62+
}

0 commit comments

Comments
 (0)