Skip to content

Commit 08ba69b

Browse files
committed
Revert "[5.7-04182022][ConstraintSystem] A couple of callAsFunction fixes (#58795)"
This reverts commit 6356f66.
1 parent e8d5e00 commit 08ba69b

File tree

3 files changed

+0
-64
lines changed

3 files changed

+0
-64
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10926,24 +10926,6 @@ bool ConstraintSystem::simplifyAppliedOverloadsImpl(
1092610926

1092710927
auto *argList = getArgumentList(getConstraintLocator(locator));
1092810928

10929-
// If argument list has trailing closures and this is `init` call to
10930-
// a callable type, let's not filter anything since there is a possibility
10931-
// that it needs an implicit `.callAsFunction` to work.
10932-
if (argList && argList->hasAnyTrailingClosures()) {
10933-
if (disjunction->getLocator()
10934-
->isLastElement<LocatorPathElt::ConstructorMember>()) {
10935-
auto choice = disjunction->getNestedConstraints()[0]->getOverloadChoice();
10936-
if (auto *decl = choice.getDeclOrNull()) {
10937-
auto *dc = decl->getDeclContext();
10938-
if (auto *parent = dc->getSelfNominalTypeDecl()) {
10939-
auto type = parent->getDeclaredInterfaceType();
10940-
if (type->isCallableNominalType(DC))
10941-
return false;
10942-
}
10943-
}
10944-
}
10945-
}
10946-
1094710929
// Consider each of the constraints in the disjunction.
1094810930
retry_after_fail:
1094910931
bool hasUnhandledConstraints = false;

test/Constraints/callAsFunction.swift

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,3 @@ struct Test {
2929
}
3030
}
3131
}
32-
33-
// rdar://92912878 - filtering prevents disambiguation of `.callAsFunction`
34-
func test_no_filtering_of_overloads() {
35-
struct S {
36-
init() {}
37-
init(_: String) {}
38-
39-
func callAsFunction<T>(_ fn: () -> T) -> T {
40-
fn()
41-
}
42-
}
43-
44-
func test(_: () -> Void) {
45-
}
46-
47-
test {
48-
_ = S() { // Ok
49-
_ = 42
50-
print("Hello")
51-
}
52-
}
53-
}

test/Constraints/result_builder.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,27 +1174,3 @@ let list3 = list {
11741174
}
11751175
print(list3)
11761176
// CHECK: (cons "4" (cons (cons "3" (cons 2.0 nil)) (cons 1 nil)))
1177-
1178-
func test_callAsFunction_with_resultBuilder() {
1179-
struct CallableTest {
1180-
func callAsFunction<T>(@TupleBuilder _ body: (Bool) -> T) {
1181-
print(body(true))
1182-
}
1183-
}
1184-
1185-
CallableTest() {
1186-
0
1187-
"with parens"
1188-
$0
1189-
}
1190-
1191-
CallableTest {
1192-
1
1193-
"without parens"
1194-
$0
1195-
}
1196-
}
1197-
1198-
test_callAsFunction_with_resultBuilder()
1199-
// CHECK: (0, "with parens", true)
1200-
// CHECK: (1, "without parens", true)

0 commit comments

Comments
 (0)