@@ -4700,31 +4700,6 @@ class ConstraintSystem {
4700
4700
Error
4701
4701
};
4702
4702
4703
- class TypeMatchResult {
4704
- SolutionKind Kind;
4705
-
4706
- public:
4707
- inline bool isSuccess () const { return Kind == SolutionKind::Solved; }
4708
- inline bool isFailure () const { return Kind == SolutionKind::Error; }
4709
- inline bool isAmbiguous () const { return Kind == SolutionKind::Unsolved; }
4710
-
4711
- static TypeMatchResult success () {
4712
- return {SolutionKind::Solved};
4713
- }
4714
-
4715
- static TypeMatchResult failure () {
4716
- return {SolutionKind::Error};
4717
- }
4718
-
4719
- static TypeMatchResult ambiguous () {
4720
- return {SolutionKind::Unsolved};
4721
- }
4722
-
4723
- operator SolutionKind () { return Kind; }
4724
- private:
4725
- TypeMatchResult (SolutionKind result) : Kind(result) {}
4726
- };
4727
-
4728
4703
// / Attempt to repair typing failures and record fixes if needed.
4729
4704
// / \return true if at least some of the failures has been repaired
4730
4705
// / successfully, which allows type matcher to continue.
@@ -4733,12 +4708,12 @@ class ConstraintSystem {
4733
4708
SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
4734
4709
ConstraintLocatorBuilder locator);
4735
4710
4736
- TypeMatchResult
4711
+ SolutionKind
4737
4712
matchPackTypes (PackType *pack1, PackType *pack2,
4738
4713
ConstraintKind kind, TypeMatchOptions flags,
4739
4714
ConstraintLocatorBuilder locator);
4740
4715
4741
- TypeMatchResult
4716
+ SolutionKind
4742
4717
matchPackExpansionTypes (PackExpansionType *expansion1,
4743
4718
PackExpansionType *expansion2,
4744
4719
ConstraintKind kind, TypeMatchOptions flags,
@@ -4747,13 +4722,13 @@ class ConstraintSystem {
4747
4722
// / Subroutine of \c matchTypes(), which matches up two tuple types.
4748
4723
// /
4749
4724
// / \returns the result of performing the tuple-to-tuple conversion.
4750
- TypeMatchResult matchTupleTypes (TupleType *tuple1, TupleType *tuple2,
4751
- ConstraintKind kind, TypeMatchOptions flags,
4752
- ConstraintLocatorBuilder locator);
4725
+ SolutionKind matchTupleTypes (TupleType *tuple1, TupleType *tuple2,
4726
+ ConstraintKind kind, TypeMatchOptions flags,
4727
+ ConstraintLocatorBuilder locator);
4753
4728
4754
4729
// / Subroutine of \c matchTypes(), which matches up two function
4755
4730
// / types.
4756
- TypeMatchResult matchFunctionTypes (FunctionType *func1, FunctionType *func2,
4731
+ SolutionKind matchFunctionTypes (FunctionType *func1, FunctionType *func2,
4757
4732
ConstraintKind kind, TypeMatchOptions flags,
4758
4733
ConstraintLocatorBuilder locator);
4759
4734
@@ -4764,14 +4739,14 @@ class ConstraintSystem {
4764
4739
4765
4740
// / Subroutine of \c matchTypes(), which matches up a value to a
4766
4741
// / superclass.
4767
- TypeMatchResult matchSuperclassTypes (Type type1, Type type2,
4768
- TypeMatchOptions flags,
4769
- ConstraintLocatorBuilder locator);
4742
+ SolutionKind matchSuperclassTypes (Type type1, Type type2,
4743
+ TypeMatchOptions flags,
4744
+ ConstraintLocatorBuilder locator);
4770
4745
4771
4746
// / Subroutine of \c matchTypes(), which matches up two types that
4772
4747
// / refer to the same declaration via their generic arguments.
4773
- TypeMatchResult matchDeepEqualityTypes (Type type1, Type type2,
4774
- ConstraintLocatorBuilder locator);
4748
+ SolutionKind matchDeepEqualityTypes (Type type1, Type type2,
4749
+ ConstraintLocatorBuilder locator);
4775
4750
4776
4751
// / Subroutine of \c matchTypes(), which matches up a value to an
4777
4752
// / existential type.
@@ -4780,23 +4755,23 @@ class ConstraintSystem {
4780
4755
// / Usually this uses Subtype, but when matching the instance type of a
4781
4756
// / metatype with the instance type of an existential metatype, since we
4782
4757
// / want an actual conformance check.
4783
- TypeMatchResult matchExistentialTypes (Type type1, Type type2,
4784
- ConstraintKind kind,
4785
- TypeMatchOptions flags,
4786
- ConstraintLocatorBuilder locator);
4758
+ SolutionKind matchExistentialTypes (Type type1, Type type2,
4759
+ ConstraintKind kind,
4760
+ TypeMatchOptions flags,
4761
+ ConstraintLocatorBuilder locator);
4787
4762
4788
4763
// / Subroutine of \c matchTypes(), used to bind a type to a
4789
4764
// / type variable.
4790
- TypeMatchResult matchTypesBindTypeVar (
4765
+ SolutionKind matchTypesBindTypeVar (
4791
4766
TypeVariableType *typeVar, Type type, ConstraintKind kind,
4792
4767
TypeMatchOptions flags, ConstraintLocatorBuilder locator,
4793
- llvm::function_ref<TypeMatchResult ()> formUnsolvedResult);
4768
+ llvm::function_ref<SolutionKind ()> formUnsolvedResult);
4794
4769
4795
4770
// / Matches two function result types for a function application. This is
4796
4771
// / usually a bind, but also handles e.g IUO unwraps.
4797
- TypeMatchResult matchFunctionResultTypes (Type expectedResult, Type fnResult,
4798
- TypeMatchOptions flags,
4799
- ConstraintLocatorBuilder locator);
4772
+ SolutionKind matchFunctionResultTypes (Type expectedResult, Type fnResult,
4773
+ TypeMatchOptions flags,
4774
+ ConstraintLocatorBuilder locator);
4800
4775
4801
4776
public: // FIXME: public due to statics in CSSimplify.cpp
4802
4777
// / Attempt to match up types \c type1 and \c type2, which in effect
@@ -4816,21 +4791,9 @@ class ConstraintSystem {
4816
4791
// / the specific types being matched.
4817
4792
// /
4818
4793
// / \returns the result of attempting to solve this constraint.
4819
- TypeMatchResult matchTypes (Type type1, Type type2, ConstraintKind kind,
4820
- TypeMatchOptions flags,
4821
- ConstraintLocatorBuilder locator);
4822
-
4823
- TypeMatchResult getTypeMatchSuccess () {
4824
- return TypeMatchResult::success ();
4825
- }
4826
-
4827
- TypeMatchResult getTypeMatchFailure (ConstraintLocatorBuilder locator) {
4828
- return TypeMatchResult::failure ();
4829
- }
4830
-
4831
- TypeMatchResult getTypeMatchAmbiguous () {
4832
- return TypeMatchResult::ambiguous ();
4833
- }
4794
+ SolutionKind matchTypes (Type type1, Type type2, ConstraintKind kind,
4795
+ TypeMatchOptions flags,
4796
+ ConstraintLocatorBuilder locator);
4834
4797
4835
4798
public:
4836
4799
// Build a disjunction that attempts both T? and T for a particular
@@ -5244,7 +5207,7 @@ class ConstraintSystem {
5244
5207
// /
5245
5208
// / \returns \c None when the result builder cannot be applied at all,
5246
5209
// / otherwise the result of applying the result builder.
5247
- std::optional<TypeMatchResult >
5210
+ std::optional<SolutionKind >
5248
5211
matchResultBuilder (AnyFunctionRef fn, Type builderType, Type bodyResultType,
5249
5212
ConstraintKind bodyResultConstraintKind,
5250
5213
Type contextualType, ConstraintLocatorBuilder locator);
@@ -5259,7 +5222,7 @@ class ConstraintSystem {
5259
5222
5260
5223
// / Matches a wrapped or projected value parameter type to its backing
5261
5224
// / property wrapper type by applying the property wrapper.
5262
- TypeMatchResult applyPropertyWrapperToParameter (
5225
+ SolutionKind applyPropertyWrapperToParameter (
5263
5226
Type wrapperType, Type paramType, ParamDecl *param, Identifier argLabel,
5264
5227
ConstraintKind matchKind, ConstraintLocator *locator,
5265
5228
ConstraintLocator *calleeLocator);
0 commit comments