Skip to content

Revert changes related to Void binding favoring #77936

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 3 commits into from
Dec 4, 2024
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
4 changes: 0 additions & 4 deletions include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,6 @@ class TypeVariableType::Implementation {
/// Determine whether this type variable represents a subscript result type.
bool isSubscriptResultType() const;

/// Determine whether this type variable represents a result type of an
/// application i.e. a call, an operator, or a subscript.
bool isApplicationResultType() const;

/// Determine whether this type variable represents an opened
/// type parameter pack.
bool isParameterPack() const;
Expand Down
16 changes: 4 additions & 12 deletions lib/Sema/CSBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,8 +1264,7 @@ static bool hasConversions(Type type) {
}

return !(type->is<StructType>() || type->is<EnumType>() ||
type->is<BuiltinType>() || type->is<ArchetypeType>() ||
type->isVoid());
type->is<BuiltinType>() || type->is<ArchetypeType>());
}

bool BindingSet::favoredOverDisjunction(Constraint *disjunction) const {
Expand All @@ -1281,16 +1280,9 @@ bool BindingSet::favoredOverDisjunction(Constraint *disjunction) const {

return !hasConversions(binding.BindingType);
})) {
bool isApplicationResultType = TypeVar->getImpl().isApplicationResultType();
if (llvm::none_of(Info.DelayedBy, [&isApplicationResultType](
const Constraint *constraint) {
// Let's not attempt to bind result type before application
// happens. For example because it could be discardable or
// l-value (subscript applications).
if (isApplicationResultType &&
constraint->getKind() == ConstraintKind::ApplicableFunction)
return true;

// Result type of subscript could be l-value so we can't bind it early.
if (!TypeVar->getImpl().isSubscriptResultType() &&
llvm::none_of(Info.DelayedBy, [](const Constraint *constraint) {
return constraint->getKind() == ConstraintKind::Disjunction ||
constraint->getKind() == ConstraintKind::ValueMember;
}))
Expand Down
10 changes: 0 additions & 10 deletions lib/Sema/TypeCheckConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,6 @@ bool TypeVariableType::Implementation::isSubscriptResultType() const {
KeyPathExpr::Component::Kind::UnresolvedSubscript;
}

bool TypeVariableType::Implementation::isApplicationResultType() const {
if (!(locator && locator->getAnchor()))
return false;

if (!locator->isLastElement<LocatorPathElt::FunctionResult>())
return false;

return isExpr<ApplyExpr>(locator->getAnchor()) || isSubscriptResultType();
}

bool TypeVariableType::Implementation::isParameterPack() const {
return locator
&& locator->isForGenericParameter()
Expand Down