@@ -2183,6 +2183,7 @@ ConstraintSystem::matchTupleTypes(TupleType *tuple1, TupleType *tuple2,
2183
2183
case ConstraintKind::ValueMember:
2184
2184
case ConstraintKind::ValueWitness:
2185
2185
case ConstraintKind::BridgingConversion:
2186
+ case ConstraintKind::OneWayEqual:
2186
2187
case ConstraintKind::FallbackType:
2187
2188
case ConstraintKind::UnresolvedMemberChainBase:
2188
2189
case ConstraintKind::PropertyWrapper:
@@ -2544,6 +2545,7 @@ static bool matchFunctionRepresentations(FunctionType::ExtInfo einfo1,
2544
2545
case ConstraintKind::UnresolvedValueMember:
2545
2546
case ConstraintKind::ValueMember:
2546
2547
case ConstraintKind::ValueWitness:
2548
+ case ConstraintKind::OneWayEqual:
2547
2549
case ConstraintKind::FallbackType:
2548
2550
case ConstraintKind::UnresolvedMemberChainBase:
2549
2551
case ConstraintKind::PropertyWrapper:
@@ -3187,6 +3189,7 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
3187
3189
case ConstraintKind::ValueMember:
3188
3190
case ConstraintKind::ValueWitness:
3189
3191
case ConstraintKind::BridgingConversion:
3192
+ case ConstraintKind::OneWayEqual:
3190
3193
case ConstraintKind::FallbackType:
3191
3194
case ConstraintKind::UnresolvedMemberChainBase:
3192
3195
case ConstraintKind::PropertyWrapper:
@@ -7128,6 +7131,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
7128
7131
case ConstraintKind::UnresolvedValueMember:
7129
7132
case ConstraintKind::ValueMember:
7130
7133
case ConstraintKind::ValueWitness:
7134
+ case ConstraintKind::OneWayEqual:
7131
7135
case ConstraintKind::FallbackType:
7132
7136
case ConstraintKind::UnresolvedMemberChainBase:
7133
7137
case ConstraintKind::PropertyWrapper:
@@ -11608,6 +11612,38 @@ ConstraintSystem::simplifyPropertyWrapperConstraint(
11608
11612
return SolutionKind::Solved;
11609
11613
}
11610
11614
11615
+ ConstraintSystem::SolutionKind
11616
+ ConstraintSystem::simplifyOneWayConstraint(
11617
+ ConstraintKind kind,
11618
+ Type first, Type second, TypeMatchOptions flags,
11619
+ ConstraintLocatorBuilder locator) {
11620
+ // Determine whether the second type can be fully simplified. Only then
11621
+ // will this constraint be resolved.
11622
+ Type secondSimplified = simplifyType(second);
11623
+ if (secondSimplified->hasTypeVariable()) {
11624
+ if (flags.contains(TMF_GenerateConstraints)) {
11625
+ addUnsolvedConstraint(
11626
+ Constraint::create(*this, kind, first, second,
11627
+ getConstraintLocator(locator)));
11628
+ return SolutionKind::Solved;
11629
+ }
11630
+
11631
+ return SolutionKind::Unsolved;
11632
+ }
11633
+
11634
+ // Propagate holes through one-way constraints.
11635
+ if (secondSimplified->isPlaceholder()) {
11636
+ recordAnyTypeVarAsPotentialHole(first);
11637
+ return SolutionKind::Solved;
11638
+ }
11639
+
11640
+ // Translate this constraint into an equality or bind-parameter constraint,
11641
+ // as appropriate.
11642
+ ASSERT(kind == ConstraintKind::OneWayEqual);
11643
+ return matchTypes(first, secondSimplified, ConstraintKind::Equal, flags,
11644
+ locator);
11645
+ }
11646
+
11611
11647
ConstraintSystem::SolutionKind
11612
11648
ConstraintSystem::simplifyUnresolvedMemberChainBaseConstraint(
11613
11649
Type first, Type second, TypeMatchOptions flags,
@@ -15685,6 +15721,9 @@ ConstraintSystem::addConstraintImpl(ConstraintKind kind, Type first,
15685
15721
case ConstraintKind::PropertyWrapper:
15686
15722
return simplifyPropertyWrapperConstraint(first, second, subflags, locator);
15687
15723
15724
+ case ConstraintKind::OneWayEqual:
15725
+ return simplifyOneWayConstraint(kind, first, second, subflags, locator);
15726
+
15688
15727
case ConstraintKind::UnresolvedMemberChainBase:
15689
15728
return simplifyUnresolvedMemberChainBaseConstraint(first, second, subflags,
15690
15729
locator);
@@ -16262,6 +16301,12 @@ ConstraintSystem::simplifyConstraint(const Constraint &constraint) {
16262
16301
// See {Dis, Con}junctionStep class in CSStep.cpp for solving
16263
16302
return SolutionKind::Unsolved;
16264
16303
16304
+ case ConstraintKind::OneWayEqual:
16305
+ return simplifyOneWayConstraint(
16306
+ constraint.getKind(), constraint.getFirstType(),
16307
+ constraint.getSecondType(),
16308
+ /*flags*/ std::nullopt, constraint.getLocator());
16309
+
16265
16310
case ConstraintKind::UnresolvedMemberChainBase:
16266
16311
return simplifyUnresolvedMemberChainBaseConstraint(
16267
16312
constraint.getFirstType(), constraint.getSecondType(),
0 commit comments