Skip to content

[ConstraintSystem] Use correct locator when filtering disjunction cho… #36300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Sema/CSSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9380,7 +9380,7 @@ bool ConstraintSystem::simplifyAppliedOverloads(
AppliedDisjunctions[disjunction->getLocator()] = argFnType;
return simplifyAppliedOverloadsImpl(disjunction, fnTypeVar, argFnType,
/*numOptionalUnwraps*/ result->second,
locator);
applicableFn->getLocator());
}

bool ConstraintSystem::simplifyAppliedOverloads(
Expand Down
22 changes: 22 additions & 0 deletions test/Constraints/overload_filtering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,25 @@ func testUnresolvedMember(i: Int) -> X {
// CHECK-NEXT: introducing single enabled disjunction term {{.*}} bound to decl overload_filtering.(file).X.init(_:_:)
return .init(i, i)
}

func test_member_filtering() {
struct S {
// Result types here are different intentionally,
// if there were the same simplication logic would
// trigger and disable overloads during constraint
// generation.
func foo(_: Int) -> S { S() }
func foo(_: String) -> Int { 42 }

func bar(v: String) {}
func bar(_: Int) {}
func bar(a: Double, b: Int) {}
}

func test(s: S) {
// CHECK: disabled disjunction term {{.*}} bound to decl overload_filtering.(file).test_member_filtering().S.bar(v:)
// CHECK-NEXT: disabled disjunction term {{.*}} bound to decl overload_filtering.(file).test_member_filtering().S.bar(a:b:)
// CHECK-NEXT: introducing single enabled disjunction term {{.*}} bound to decl overload_filtering.(file).test_member_filtering().S.bar
s.foo(42).bar(42)
}
}