Skip to content

Commit 08720ee

Browse files
authored
Merge pull request #77936 from xedin/revert-void-favoring
Revert changes related to `Void` binding favoring
2 parents b623958 + 92a1b1f commit 08720ee

File tree

3 files changed

+4
-26
lines changed

3 files changed

+4
-26
lines changed

include/swift/Sema/ConstraintSystem.h

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

485-
/// Determine whether this type variable represents a result type of an
486-
/// application i.e. a call, an operator, or a subscript.
487-
bool isApplicationResultType() const;
488-
489485
/// Determine whether this type variable represents an opened
490486
/// type parameter pack.
491487
bool isParameterPack() const;

lib/Sema/CSBindings.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,7 @@ static bool hasConversions(Type type) {
12651265
}
12661266

12671267
return !(type->is<StructType>() || type->is<EnumType>() ||
1268-
type->is<BuiltinType>() || type->is<ArchetypeType>() ||
1269-
type->isVoid());
1268+
type->is<BuiltinType>() || type->is<ArchetypeType>());
12701269
}
12711270

12721271
bool BindingSet::favoredOverDisjunction(Constraint *disjunction) const {
@@ -1282,16 +1281,9 @@ bool BindingSet::favoredOverDisjunction(Constraint *disjunction) const {
12821281

12831282
return !hasConversions(binding.BindingType);
12841283
})) {
1285-
bool isApplicationResultType = TypeVar->getImpl().isApplicationResultType();
1286-
if (llvm::none_of(Info.DelayedBy, [&isApplicationResultType](
1287-
const Constraint *constraint) {
1288-
// Let's not attempt to bind result type before application
1289-
// happens. For example because it could be discardable or
1290-
// l-value (subscript applications).
1291-
if (isApplicationResultType &&
1292-
constraint->getKind() == ConstraintKind::ApplicableFunction)
1293-
return true;
1294-
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) {
12951287
return constraint->getKind() == ConstraintKind::Disjunction ||
12961288
constraint->getKind() == ConstraintKind::ValueMember;
12971289
}))

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()

0 commit comments

Comments
 (0)