@@ -4688,31 +4688,6 @@ class ConstraintSystem {
4688
4688
Error
4689
4689
};
4690
4690
4691
- class TypeMatchResult {
4692
- SolutionKind Kind;
4693
-
4694
- public:
4695
- inline bool isSuccess () const { return Kind == SolutionKind::Solved; }
4696
- inline bool isFailure () const { return Kind == SolutionKind::Error; }
4697
- inline bool isAmbiguous () const { return Kind == SolutionKind::Unsolved; }
4698
-
4699
- static TypeMatchResult success () {
4700
- return {SolutionKind::Solved};
4701
- }
4702
-
4703
- static TypeMatchResult failure () {
4704
- return {SolutionKind::Error};
4705
- }
4706
-
4707
- static TypeMatchResult ambiguous () {
4708
- return {SolutionKind::Unsolved};
4709
- }
4710
-
4711
- operator SolutionKind () { return Kind; }
4712
- private:
4713
- TypeMatchResult (SolutionKind result) : Kind(result) {}
4714
- };
4715
-
4716
4691
// / Attempt to repair typing failures and record fixes if needed.
4717
4692
// / \return true if at least some of the failures has been repaired
4718
4693
// / successfully, which allows type matcher to continue.
@@ -4721,12 +4696,12 @@ class ConstraintSystem {
4721
4696
SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
4722
4697
ConstraintLocatorBuilder locator);
4723
4698
4724
- TypeMatchResult
4699
+ SolutionKind
4725
4700
matchPackTypes (PackType *pack1, PackType *pack2,
4726
4701
ConstraintKind kind, TypeMatchOptions flags,
4727
4702
ConstraintLocatorBuilder locator);
4728
4703
4729
- TypeMatchResult
4704
+ SolutionKind
4730
4705
matchPackExpansionTypes (PackExpansionType *expansion1,
4731
4706
PackExpansionType *expansion2,
4732
4707
ConstraintKind kind, TypeMatchOptions flags,
@@ -4735,13 +4710,13 @@ class ConstraintSystem {
4735
4710
// / Subroutine of \c matchTypes(), which matches up two tuple types.
4736
4711
// /
4737
4712
// / \returns the result of performing the tuple-to-tuple conversion.
4738
- TypeMatchResult matchTupleTypes (TupleType *tuple1, TupleType *tuple2,
4739
- ConstraintKind kind, TypeMatchOptions flags,
4740
- ConstraintLocatorBuilder locator);
4713
+ SolutionKind matchTupleTypes (TupleType *tuple1, TupleType *tuple2,
4714
+ ConstraintKind kind, TypeMatchOptions flags,
4715
+ ConstraintLocatorBuilder locator);
4741
4716
4742
4717
// / Subroutine of \c matchTypes(), which matches up two function
4743
4718
// / types.
4744
- TypeMatchResult matchFunctionTypes (FunctionType *func1, FunctionType *func2,
4719
+ SolutionKind matchFunctionTypes (FunctionType *func1, FunctionType *func2,
4745
4720
ConstraintKind kind, TypeMatchOptions flags,
4746
4721
ConstraintLocatorBuilder locator);
4747
4722
@@ -4752,14 +4727,14 @@ class ConstraintSystem {
4752
4727
4753
4728
// / Subroutine of \c matchTypes(), which matches up a value to a
4754
4729
// / superclass.
4755
- TypeMatchResult matchSuperclassTypes (Type type1, Type type2,
4756
- TypeMatchOptions flags,
4757
- ConstraintLocatorBuilder locator);
4730
+ SolutionKind matchSuperclassTypes (Type type1, Type type2,
4731
+ TypeMatchOptions flags,
4732
+ ConstraintLocatorBuilder locator);
4758
4733
4759
4734
// / Subroutine of \c matchTypes(), which matches up two types that
4760
4735
// / refer to the same declaration via their generic arguments.
4761
- TypeMatchResult matchDeepEqualityTypes (Type type1, Type type2,
4762
- ConstraintLocatorBuilder locator);
4736
+ SolutionKind matchDeepEqualityTypes (Type type1, Type type2,
4737
+ ConstraintLocatorBuilder locator);
4763
4738
4764
4739
// / Subroutine of \c matchTypes(), which matches up a value to an
4765
4740
// / existential type.
@@ -4768,23 +4743,23 @@ class ConstraintSystem {
4768
4743
// / Usually this uses Subtype, but when matching the instance type of a
4769
4744
// / metatype with the instance type of an existential metatype, since we
4770
4745
// / want an actual conformance check.
4771
- TypeMatchResult matchExistentialTypes (Type type1, Type type2,
4772
- ConstraintKind kind,
4773
- TypeMatchOptions flags,
4774
- ConstraintLocatorBuilder locator);
4746
+ SolutionKind matchExistentialTypes (Type type1, Type type2,
4747
+ ConstraintKind kind,
4748
+ TypeMatchOptions flags,
4749
+ ConstraintLocatorBuilder locator);
4775
4750
4776
4751
// / Subroutine of \c matchTypes(), used to bind a type to a
4777
4752
// / type variable.
4778
- TypeMatchResult matchTypesBindTypeVar (
4753
+ SolutionKind matchTypesBindTypeVar (
4779
4754
TypeVariableType *typeVar, Type type, ConstraintKind kind,
4780
4755
TypeMatchOptions flags, ConstraintLocatorBuilder locator,
4781
- llvm::function_ref<TypeMatchResult ()> formUnsolvedResult);
4756
+ llvm::function_ref<SolutionKind ()> formUnsolvedResult);
4782
4757
4783
4758
// / Matches two function result types for a function application. This is
4784
4759
// / usually a bind, but also handles e.g IUO unwraps.
4785
- TypeMatchResult matchFunctionResultTypes (Type expectedResult, Type fnResult,
4786
- TypeMatchOptions flags,
4787
- ConstraintLocatorBuilder locator);
4760
+ SolutionKind matchFunctionResultTypes (Type expectedResult, Type fnResult,
4761
+ TypeMatchOptions flags,
4762
+ ConstraintLocatorBuilder locator);
4788
4763
4789
4764
public: // FIXME: public due to statics in CSSimplify.cpp
4790
4765
// / Attempt to match up types \c type1 and \c type2, which in effect
@@ -4804,21 +4779,9 @@ class ConstraintSystem {
4804
4779
// / the specific types being matched.
4805
4780
// /
4806
4781
// / \returns the result of attempting to solve this constraint.
4807
- TypeMatchResult matchTypes (Type type1, Type type2, ConstraintKind kind,
4808
- TypeMatchOptions flags,
4809
- ConstraintLocatorBuilder locator);
4810
-
4811
- TypeMatchResult getTypeMatchSuccess () {
4812
- return TypeMatchResult::success ();
4813
- }
4814
-
4815
- TypeMatchResult getTypeMatchFailure (ConstraintLocatorBuilder locator) {
4816
- return TypeMatchResult::failure ();
4817
- }
4818
-
4819
- TypeMatchResult getTypeMatchAmbiguous () {
4820
- return TypeMatchResult::ambiguous ();
4821
- }
4782
+ SolutionKind matchTypes (Type type1, Type type2, ConstraintKind kind,
4783
+ TypeMatchOptions flags,
4784
+ ConstraintLocatorBuilder locator);
4822
4785
4823
4786
public:
4824
4787
// Build a disjunction that attempts both T? and T for a particular
@@ -5232,7 +5195,7 @@ class ConstraintSystem {
5232
5195
// /
5233
5196
// / \returns \c None when the result builder cannot be applied at all,
5234
5197
// / otherwise the result of applying the result builder.
5235
- std::optional<TypeMatchResult >
5198
+ std::optional<SolutionKind >
5236
5199
matchResultBuilder (AnyFunctionRef fn, Type builderType, Type bodyResultType,
5237
5200
ConstraintKind bodyResultConstraintKind,
5238
5201
Type contextualType, ConstraintLocatorBuilder locator);
@@ -5247,7 +5210,7 @@ class ConstraintSystem {
5247
5210
5248
5211
// / Matches a wrapped or projected value parameter type to its backing
5249
5212
// / property wrapper type by applying the property wrapper.
5250
- TypeMatchResult applyPropertyWrapperToParameter (
5213
+ SolutionKind applyPropertyWrapperToParameter (
5251
5214
Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
5252
5215
ConstraintKind matchKind, ConstraintLocator *locator,
5253
5216
ConstraintLocator *calleeLocator);
0 commit comments