Skip to content

Commit a449da9

Browse files
committed
Sema: Remove ConstraintKind::OneWayEqual
1 parent 3c7c233 commit a449da9

File tree

6 files changed

+1
-109
lines changed

6 files changed

+1
-109
lines changed

include/swift/Sema/Constraint.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ enum class ConstraintKind : char {
150150
/// The key path type is chosen based on the selection of overloads for the
151151
/// member references along the path.
152152
KeyPath,
153-
/// The first type will be equal to the second type, but only when the
154-
/// second type has been fully determined (and mapped down to a concrete
155-
/// type). At that point, this constraint will be treated like an `Equal`
156-
/// constraint.
157-
OneWayEqual,
158153
/// If there is no contextual info e.g. `_ = { 42 }` default first type
159154
/// to a second type. This is effectively a `Defaultable` constraint
160155
/// which one significant difference:
@@ -680,7 +675,6 @@ class Constraint final : public llvm::ilist_node<Constraint>,
680675
case ConstraintKind::DynamicCallableApplicableFunction:
681676
case ConstraintKind::BindOverload:
682677
case ConstraintKind::OptionalObject:
683-
case ConstraintKind::OneWayEqual:
684678
case ConstraintKind::FallbackType:
685679
case ConstraintKind::UnresolvedMemberChainBase:
686680
case ConstraintKind::PackElementOf:
@@ -828,7 +822,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
828822

829823
/// Whether this is a one-way constraint.
830824
bool isOneWayConstraint() const {
831-
return Kind == ConstraintKind::OneWayEqual;
825+
return false;
832826
}
833827

834828
/// Retrieve the overload choice for an overload-binding constraint.

include/swift/Sema/ConstraintSystem.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5011,12 +5011,6 @@ class ConstraintSystem {
50115011
TypeMatchOptions flags,
50125012
ConstraintLocatorBuilder locator);
50135013

5014-
/// Attempt to simplify a one-way constraint.
5015-
SolutionKind simplifyOneWayConstraint(ConstraintKind kind,
5016-
Type first, Type second,
5017-
TypeMatchOptions flags,
5018-
ConstraintLocatorBuilder locator);
5019-
50205014
/// Simplify an equality constraint between result and base types of
50215015
/// an unresolved member chain.
50225016
SolutionKind simplifyUnresolvedMemberChainBaseConstraint(

lib/Sema/CSBindings.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,20 +1949,6 @@ void PotentialBindings::infer(ConstraintSystem &CS,
19491949

19501950
break;
19511951
}
1952-
1953-
case ConstraintKind::OneWayEqual:{
1954-
// Don't produce any bindings if this type variable is on the left-hand
1955-
// side of a one-way binding.
1956-
auto firstType = constraint->getFirstType();
1957-
if (auto *tv = firstType->getAs<TypeVariableType>()) {
1958-
if (tv->getImpl().getRepresentative(nullptr) == TypeVar) {
1959-
DelayedBy.push_back(constraint);
1960-
break;
1961-
}
1962-
}
1963-
1964-
break;
1965-
}
19661952
}
19671953
}
19681954

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,6 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
21802180
case ConstraintKind::ValueMember:
21812181
case ConstraintKind::ValueWitness:
21822182
case ConstraintKind::BridgingConversion:
2183-
case ConstraintKind::OneWayEqual:
21842183
case ConstraintKind::FallbackType:
21852184
case ConstraintKind::UnresolvedMemberChainBase:
21862185
case ConstraintKind::PropertyWrapper:
@@ -2551,7 +2550,6 @@ static bool matchFunctionRepresentations(FunctionType::ExtInfo einfo1,
25512550
case ConstraintKind::UnresolvedValueMember:
25522551
case ConstraintKind::ValueMember:
25532552
case ConstraintKind::ValueWitness:
2554-
case ConstraintKind::OneWayEqual:
25552553
case ConstraintKind::FallbackType:
25562554
case ConstraintKind::UnresolvedMemberChainBase:
25572555
case ConstraintKind::PropertyWrapper:
@@ -3195,7 +3193,6 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
31953193
case ConstraintKind::ValueMember:
31963194
case ConstraintKind::ValueWitness:
31973195
case ConstraintKind::BridgingConversion:
3198-
case ConstraintKind::OneWayEqual:
31993196
case ConstraintKind::FallbackType:
32003197
case ConstraintKind::UnresolvedMemberChainBase:
32013198
case ConstraintKind::PropertyWrapper:
@@ -7130,7 +7127,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
71307127
case ConstraintKind::UnresolvedValueMember:
71317128
case ConstraintKind::ValueMember:
71327129
case ConstraintKind::ValueWitness:
7133-
case ConstraintKind::OneWayEqual:
71347130
case ConstraintKind::FallbackType:
71357131
case ConstraintKind::UnresolvedMemberChainBase:
71367132
case ConstraintKind::PropertyWrapper:
@@ -11563,38 +11559,6 @@ ConstraintSystem::simplifyPropertyWrapperConstraint(
1156311559
return SolutionKind::Solved;
1156411560
}
1156511561

11566-
ConstraintSystem::SolutionKind
11567-
ConstraintSystem::simplifyOneWayConstraint(
11568-
ConstraintKind kind,
11569-
Type first, Type second, TypeMatchOptions flags,
11570-
ConstraintLocatorBuilder locator) {
11571-
// Determine whether the second type can be fully simplified. Only then
11572-
// will this constraint be resolved.
11573-
Type secondSimplified = simplifyType(second);
11574-
if (secondSimplified->hasTypeVariable()) {
11575-
if (flags.contains(TMF_GenerateConstraints)) {
11576-
addUnsolvedConstraint(
11577-
Constraint::create(*this, kind, first, second,
11578-
getConstraintLocator(locator)));
11579-
return SolutionKind::Solved;
11580-
}
11581-
11582-
return SolutionKind::Unsolved;
11583-
}
11584-
11585-
// Propagate holes through one-way constraints.
11586-
if (secondSimplified->isPlaceholder()) {
11587-
recordAnyTypeVarAsPotentialHole(first);
11588-
return SolutionKind::Solved;
11589-
}
11590-
11591-
// Translate this constraint into an equality or bind-parameter constraint,
11592-
// as appropriate.
11593-
ASSERT(kind == ConstraintKind::OneWayEqual);
11594-
return matchTypes(first, secondSimplified, ConstraintKind::Equal, flags,
11595-
locator);
11596-
}
11597-
1159811562
ConstraintSystem::SolutionKind
1159911563
ConstraintSystem::simplifyUnresolvedMemberChainBaseConstraint(
1160011564
Type first, Type second, TypeMatchOptions flags,
@@ -15726,9 +15690,6 @@ ConstraintSystem::addConstraintImpl(ConstraintKind kind, Type first,
1572615690
case ConstraintKind::PropertyWrapper:
1572715691
return simplifyPropertyWrapperConstraint(first, second, subflags, locator);
1572815692

15729-
case ConstraintKind::OneWayEqual:
15730-
return simplifyOneWayConstraint(kind, first, second, subflags, locator);
15731-
1573215693
case ConstraintKind::UnresolvedMemberChainBase:
1573315694
return simplifyUnresolvedMemberChainBaseConstraint(first, second, subflags,
1573415695
locator);
@@ -16306,12 +16267,6 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
1630616267
// See {Dis, Con}junctionStep class in CSStep.cpp for solving
1630716268
return SolutionKind::Unsolved;
1630816269

16309-
case ConstraintKind::OneWayEqual:
16310-
return simplifyOneWayConstraint(
16311-
constraint.getKind(), constraint.getFirstType(),
16312-
constraint.getSecondType(),
16313-
/*flags*/ std::nullopt, constraint.getLocator());
16314-
1631516270
case ConstraintKind::UnresolvedMemberChainBase:
1631616271
return simplifyUnresolvedMemberChainBaseConstraint(
1631716272
constraint.getFirstType(), constraint.getSecondType(),

lib/Sema/Constraint.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
7474
case ConstraintKind::EscapableFunctionOf:
7575
case ConstraintKind::OpenedExistentialOf:
7676
case ConstraintKind::OptionalObject:
77-
case ConstraintKind::OneWayEqual:
7877
case ConstraintKind::UnresolvedMemberChainBase:
7978
case ConstraintKind::PropertyWrapper:
8079
case ConstraintKind::BindTupleOfFunctionParams:
@@ -162,7 +161,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second, Type Third,
162161
case ConstraintKind::BindOverload:
163162
case ConstraintKind::Disjunction:
164163
case ConstraintKind::Conjunction:
165-
case ConstraintKind::OneWayEqual:
166164
case ConstraintKind::FallbackType:
167165
case ConstraintKind::UnresolvedMemberChainBase:
168166
case ConstraintKind::PropertyWrapper:
@@ -395,7 +393,6 @@ void Constraint::print(llvm::raw_ostream &Out, SourceManager *sm,
395393
case ConstraintKind::DynamicTypeOf: Out << " dynamicType type of "; break;
396394
case ConstraintKind::EscapableFunctionOf: Out << " @escaping type of "; break;
397395
case ConstraintKind::OpenedExistentialOf: Out << " opened archetype of "; break;
398-
case ConstraintKind::OneWayEqual: Out << " one-way bind to "; break;
399396
case ConstraintKind::FallbackType:
400397
Out << " can fallback to ";
401398
break;
@@ -675,7 +672,6 @@ gatherReferencedTypeVars(Constraint *constraint,
675672
case ConstraintKind::ConformsTo:
676673
case ConstraintKind::LiteralConformsTo:
677674
case ConstraintKind::TransitivelyConformsTo:
678-
case ConstraintKind::OneWayEqual:
679675
case ConstraintKind::FallbackType:
680676
case ConstraintKind::UnresolvedMemberChainBase:
681677
case ConstraintKind::PropertyWrapper:

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,39 +1837,6 @@ Type Solution::simplifyTypeForCodeCompletion(Type Ty) const {
18371837
return typeVar;
18381838
});
18391839

1840-
// Logic to determine the contextual type inside buildBlock result builders:
1841-
//
1842-
// When completing inside a result builder, the result builder
1843-
// @ViewBuilder var body: some View {
1844-
// Text("Foo")
1845-
// #^COMPLETE^#
1846-
// }
1847-
// gets rewritten to
1848-
// @ViewBuilder var body: some View {
1849-
// let $__builder2: Text
1850-
// let $__builder0 = Text("Foo")
1851-
// let $__builder1 = #^COMPLETE^#
1852-
// $__builder2 = ViewBuilder.buildBlock($__builder0, $__builder1)
1853-
// return $__builder2
1854-
// }
1855-
// Inside the constraint system
1856-
// let $__builder1 = #^COMPLETE^#
1857-
// gets type checked without context, so we can't know the contextual type for
1858-
// the code completion token. But we know that $__builder1 (and thus the type
1859-
// of #^COMPLETE^#) is used as the second argument to ViewBuilder.buildBlock,
1860-
// so we can extract the contextual type from that call. To do this, figure
1861-
// out the type variable that is used for $__builder1 in the buildBlock call.
1862-
// This type variable is connected to the type variable of $__builder1's
1863-
// definition by a one-way constraint.
1864-
if (auto TV = Ty->getAs<TypeVariableType>()) {
1865-
for (auto constraint : CS.getConstraintGraph()[TV].getConstraints()) {
1866-
if (constraint->getKind() == ConstraintKind::OneWayEqual &&
1867-
constraint->getSecondType()->isEqual(TV)) {
1868-
return simplifyTypeForCodeCompletion(constraint->getFirstType());
1869-
}
1870-
}
1871-
}
1872-
18731840
// Remove any remaining type variables and placeholders
18741841
Ty = simplifyType(Ty);
18751842

0 commit comments

Comments
 (0)