Skip to content

Commit fc26ad3

Browse files
committed
Revert "[CSBindings] Don't favor application result types before application happens"
This reverts commit bc949c3. (cherry picked from commit 8aa6280)
1 parent 9bf11bc commit fc26ad3

File tree

4 files changed

+3
-41
lines changed

4 files changed

+3
-41
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ class TypeVariableType::Implementation {
486486
/// Determine whether this type variable represents a subscript result type.
487487
bool isSubscriptResultType() const;
488488

489-
/// Determine whether this type variable represents a result type of an
490-
/// application i.e. a call, an operator, or a subscript.
491-
bool isApplicationResultType() const;
492-
493489
/// Determine whether this type variable represents an opened
494490
/// type parameter pack.
495491
bool isParameterPack() const;

lib/Sema/CSBindings.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,16 +1281,9 @@ bool BindingSet::favoredOverDisjunction(Constraint *disjunction) const {
12811281

12821282
return !hasConversions(binding.BindingType);
12831283
})) {
1284-
bool isApplicationResultType = TypeVar->getImpl().isApplicationResultType();
1285-
if (llvm::none_of(Info.DelayedBy, [&isApplicationResultType](
1286-
const Constraint *constraint) {
1287-
// Let's not attempt to bind result type before application
1288-
// happens. For example because it could be discardable or
1289-
// l-value (subscript applications).
1290-
if (isApplicationResultType &&
1291-
constraint->getKind() == ConstraintKind::ApplicableFunction)
1292-
return true;
1293-
1284+
// Result type of subscript could be l-value so we can't bind it early.
1285+
if (!TypeVar->getImpl().isSubscriptResultType() &&
1286+
llvm::none_of(Info.DelayedBy, [](const Constraint *constraint) {
12941287
return constraint->getKind() == ConstraintKind::Disjunction ||
12951288
constraint->getKind() == ConstraintKind::ValueMember;
12961289
}))

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,6 @@ bool TypeVariableType::Implementation::isSubscriptResultType() const {
175175
KeyPathExpr::Component::Kind::UnresolvedSubscript;
176176
}
177177

178-
bool TypeVariableType::Implementation::isApplicationResultType() const {
179-
if (!(locator && locator->getAnchor()))
180-
return false;
181-
182-
if (!locator->isLastElement<LocatorPathElt::FunctionResult>())
183-
return false;
184-
185-
return isExpr<ApplyExpr>(locator->getAnchor()) || isSubscriptResultType();
186-
}
187-
188178
bool TypeVariableType::Implementation::isParameterPack() const {
189179
return locator
190180
&& locator->isForGenericParameter()

test/Constraints/async.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,3 @@ struct OverloadInImplicitAsyncClosure {
180180

181181
init(int: Int) throws { }
182182
}
183-
184-
@available(SwiftStdlib 5.5, *)
185-
func test(_: Int) async throws {}
186-
187-
@discardableResult
188-
@available(SwiftStdlib 5.5, *)
189-
func test(_: Int) -> String { "" }
190-
191-
@available(SwiftStdlib 5.5, *)
192-
func compute(_: @escaping () -> Void) {}
193-
194-
@available(SwiftStdlib 5.5, *)
195-
func test_sync_in_closure_context() {
196-
compute {
197-
test(42) // Ok (select sync overloads and discards the result)
198-
}
199-
}

0 commit comments

Comments
 (0)