@@ -4591,31 +4591,6 @@ class ConstraintSystem {
4591
4591
Error
4592
4592
};
4593
4593
4594
- class TypeMatchResult {
4595
- SolutionKind Kind;
4596
-
4597
- public:
4598
- inline bool isSuccess () const { return Kind == SolutionKind::Solved; }
4599
- inline bool isFailure () const { return Kind == SolutionKind::Error; }
4600
- inline bool isAmbiguous () const { return Kind == SolutionKind::Unsolved; }
4601
-
4602
- static TypeMatchResult success () {
4603
- return {SolutionKind::Solved};
4604
- }
4605
-
4606
- static TypeMatchResult failure () {
4607
- return {SolutionKind::Error};
4608
- }
4609
-
4610
- static TypeMatchResult ambiguous () {
4611
- return {SolutionKind::Unsolved};
4612
- }
4613
-
4614
- operator SolutionKind () { return Kind; }
4615
- private:
4616
- TypeMatchResult (SolutionKind result) : Kind(result) {}
4617
- };
4618
-
4619
4594
// / Attempt to repair typing failures and record fixes if needed.
4620
4595
// / \return true if at least some of the failures has been repaired
4621
4596
// / successfully, which allows type matcher to continue.
@@ -4624,12 +4599,12 @@ class ConstraintSystem {
4624
4599
SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
4625
4600
ConstraintLocatorBuilder locator);
4626
4601
4627
- TypeMatchResult
4602
+ SolutionKind
4628
4603
matchPackTypes (PackType *pack1, PackType *pack2,
4629
4604
ConstraintKind kind, TypeMatchOptions flags,
4630
4605
ConstraintLocatorBuilder locator);
4631
4606
4632
- TypeMatchResult
4607
+ SolutionKind
4633
4608
matchPackExpansionTypes (PackExpansionType *expansion1,
4634
4609
PackExpansionType *expansion2,
4635
4610
ConstraintKind kind, TypeMatchOptions flags,
@@ -4638,13 +4613,13 @@ class ConstraintSystem {
4638
4613
// / Subroutine of \c matchTypes(), which matches up two tuple types.
4639
4614
// /
4640
4615
// / \returns the result of performing the tuple-to-tuple conversion.
4641
- TypeMatchResult matchTupleTypes (TupleType *tuple1, TupleType *tuple2,
4642
- ConstraintKind kind, TypeMatchOptions flags,
4643
- ConstraintLocatorBuilder locator);
4616
+ SolutionKind matchTupleTypes (TupleType *tuple1, TupleType *tuple2,
4617
+ ConstraintKind kind, TypeMatchOptions flags,
4618
+ ConstraintLocatorBuilder locator);
4644
4619
4645
4620
// / Subroutine of \c matchTypes(), which matches up two function
4646
4621
// / types.
4647
- TypeMatchResult matchFunctionTypes (FunctionType *func1, FunctionType *func2,
4622
+ SolutionKind matchFunctionTypes (FunctionType *func1, FunctionType *func2,
4648
4623
ConstraintKind kind, TypeMatchOptions flags,
4649
4624
ConstraintLocatorBuilder locator);
4650
4625
@@ -4655,14 +4630,14 @@ class ConstraintSystem {
4655
4630
4656
4631
// / Subroutine of \c matchTypes(), which matches up a value to a
4657
4632
// / superclass.
4658
- TypeMatchResult matchSuperclassTypes (Type type1, Type type2,
4659
- TypeMatchOptions flags,
4660
- ConstraintLocatorBuilder locator);
4633
+ SolutionKind matchSuperclassTypes (Type type1, Type type2,
4634
+ TypeMatchOptions flags,
4635
+ ConstraintLocatorBuilder locator);
4661
4636
4662
4637
// / Subroutine of \c matchTypes(), which matches up two types that
4663
4638
// / refer to the same declaration via their generic arguments.
4664
- TypeMatchResult matchDeepEqualityTypes (Type type1, Type type2,
4665
- ConstraintLocatorBuilder locator);
4639
+ SolutionKind matchDeepEqualityTypes (Type type1, Type type2,
4640
+ ConstraintLocatorBuilder locator);
4666
4641
4667
4642
// / Subroutine of \c matchTypes(), which matches up a value to an
4668
4643
// / existential type.
@@ -4671,23 +4646,23 @@ class ConstraintSystem {
4671
4646
// / Usually this uses Subtype, but when matching the instance type of a
4672
4647
// / metatype with the instance type of an existential metatype, since we
4673
4648
// / want an actual conformance check.
4674
- TypeMatchResult matchExistentialTypes (Type type1, Type type2,
4675
- ConstraintKind kind,
4676
- TypeMatchOptions flags,
4677
- ConstraintLocatorBuilder locator);
4649
+ SolutionKind matchExistentialTypes (Type type1, Type type2,
4650
+ ConstraintKind kind,
4651
+ TypeMatchOptions flags,
4652
+ ConstraintLocatorBuilder locator);
4678
4653
4679
4654
// / Subroutine of \c matchTypes(), used to bind a type to a
4680
4655
// / type variable.
4681
- TypeMatchResult matchTypesBindTypeVar (
4656
+ SolutionKind matchTypesBindTypeVar (
4682
4657
TypeVariableType *typeVar, Type type, ConstraintKind kind,
4683
4658
TypeMatchOptions flags, ConstraintLocatorBuilder locator,
4684
- llvm::function_ref<TypeMatchResult ()> formUnsolvedResult);
4659
+ llvm::function_ref<SolutionKind ()> formUnsolvedResult);
4685
4660
4686
4661
// / Matches two function result types for a function application. This is
4687
4662
// / usually a bind, but also handles e.g IUO unwraps.
4688
- TypeMatchResult matchFunctionResultTypes (Type expectedResult, Type fnResult,
4689
- TypeMatchOptions flags,
4690
- ConstraintLocatorBuilder locator);
4663
+ SolutionKind matchFunctionResultTypes (Type expectedResult, Type fnResult,
4664
+ TypeMatchOptions flags,
4665
+ ConstraintLocatorBuilder locator);
4691
4666
4692
4667
public: // FIXME: public due to statics in CSSimplify.cpp
4693
4668
// / Attempt to match up types \c type1 and \c type2, which in effect
@@ -4707,21 +4682,9 @@ class ConstraintSystem {
4707
4682
// / the specific types being matched.
4708
4683
// /
4709
4684
// / \returns the result of attempting to solve this constraint.
4710
- TypeMatchResult matchTypes (Type type1, Type type2, ConstraintKind kind,
4711
- TypeMatchOptions flags,
4712
- ConstraintLocatorBuilder locator);
4713
-
4714
- TypeMatchResult getTypeMatchSuccess () {
4715
- return TypeMatchResult::success ();
4716
- }
4717
-
4718
- TypeMatchResult getTypeMatchFailure (ConstraintLocatorBuilder locator) {
4719
- return TypeMatchResult::failure ();
4720
- }
4721
-
4722
- TypeMatchResult getTypeMatchAmbiguous () {
4723
- return TypeMatchResult::ambiguous ();
4724
- }
4685
+ SolutionKind matchTypes (Type type1, Type type2, ConstraintKind kind,
4686
+ TypeMatchOptions flags,
4687
+ ConstraintLocatorBuilder locator);
4725
4688
4726
4689
public:
4727
4690
// Build a disjunction that attempts both T? and T for a particular
@@ -5123,7 +5086,7 @@ class ConstraintSystem {
5123
5086
// /
5124
5087
// / \returns \c None when the result builder cannot be applied at all,
5125
5088
// / otherwise the result of applying the result builder.
5126
- std::optional<TypeMatchResult >
5089
+ std::optional<SolutionKind >
5127
5090
matchResultBuilder (AnyFunctionRef fn, Type builderType, Type bodyResultType,
5128
5091
ConstraintKind bodyResultConstraintKind,
5129
5092
Type contextualType, ConstraintLocatorBuilder locator);
@@ -5138,7 +5101,7 @@ class ConstraintSystem {
5138
5101
5139
5102
// / Matches a wrapped or projected value parameter type to its backing
5140
5103
// / property wrapper type by applying the property wrapper.
5141
- TypeMatchResult applyPropertyWrapperToParameter (
5104
+ SolutionKind applyPropertyWrapperToParameter (
5142
5105
Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
5143
5106
ConstraintKind matchKind, ConstraintLocator *locator,
5144
5107
ConstraintLocator *calleeLocator);
0 commit comments