@@ -553,8 +553,12 @@ template <typename T = Expr> T *castToExpr(ASTNode node) {
553
553
}
554
554
555
555
template <typename T = Expr> T *getAsExpr (ASTNode node) {
556
+ if (node.isNull ())
557
+ return nullptr ;
558
+
556
559
if (auto *E = node.dyn_cast <Expr *>())
557
560
return dyn_cast_or_null<T>(E);
561
+
558
562
return nullptr ;
559
563
}
560
564
@@ -788,6 +792,10 @@ enum ScoreKind {
788
792
SK_UnresolvedMemberViaOptional,
789
793
// / An implicit force of an implicitly unwrapped optional value.
790
794
SK_ForceUnchecked,
795
+ // / An implicit conversion from a value of one type (lhs)
796
+ // / to another type (rhs) via implicit initialization of
797
+ // / `rhs` type with an argument of `lhs` value.
798
+ SK_ImplicitValueConversion,
791
799
// / A user-defined conversion.
792
800
SK_UserConversion,
793
801
// / A non-trivial function conversion.
@@ -1169,6 +1177,10 @@ class Solution {
1169
1177
// / The locators of \c Defaultable constraints whose defaults were used.
1170
1178
llvm::SmallPtrSet<ConstraintLocator *, 2 > DefaultedConstraints;
1171
1179
1180
+ // / Implicit value conversions applied for a given locator.
1181
+ SmallVector<std::pair<ConstraintLocator *, ConversionRestrictionKind>, 2 >
1182
+ ImplicitValueConversions;
1183
+
1172
1184
// / The node -> type mappings introduced by this solution.
1173
1185
llvm::DenseMap<ASTNode, Type> nodeTypes;
1174
1186
@@ -1393,6 +1405,10 @@ enum class ConstraintSystemFlags {
1393
1405
// / calling conventions, say due to Clang attributes such as
1394
1406
// / `__attribute__((ns_consumed))`.
1395
1407
UseClangFunctionTypes = 0x80 ,
1408
+
1409
+ // / Disallow using Double and CGFloat interchangeably by means of
1410
+ // / an implicit value conversion.
1411
+ DisableImplicitDoubleCGFloatConversion = 0x100 ,
1396
1412
};
1397
1413
1398
1414
// / Options that affect the constraint system as a whole.
@@ -2202,6 +2218,11 @@ class ConstraintSystem {
2202
2218
std::vector<std::pair<ConstraintLocator*, TrailingClosureMatching>>
2203
2219
trailingClosureMatchingChoices;
2204
2220
2221
+ // / The set of implicit value conversions performed by the solver on
2222
+ // / a current path to reach a solution.
2223
+ SmallVector<std::pair<ConstraintLocator *, ConversionRestrictionKind>, 2 >
2224
+ ImplicitValueConversions;
2225
+
2205
2226
// / The worklist of "active" constraints that should be revisited
2206
2227
// / due to a change.
2207
2228
ConstraintList ActiveConstraints;
@@ -2730,6 +2751,9 @@ class ConstraintSystem {
2730
2751
// / The length of \c caseLabelItems.
2731
2752
unsigned numCaseLabelItems;
2732
2753
2754
+ // / The length of \c ImplicitValueConversions.
2755
+ unsigned numImplicitValueConversions;
2756
+
2733
2757
// / The previous score.
2734
2758
Score PreviousScore;
2735
2759
@@ -3996,7 +4020,7 @@ class ConstraintSystem {
3996
4020
// / \returns \c true if an error was encountered, \c false otherwise.
3997
4021
bool simplifyAppliedOverloadsImpl (Constraint *disjunction,
3998
4022
TypeVariableType *fnTypeVar,
3999
- const FunctionType *argFnType,
4023
+ FunctionType *argFnType,
4000
4024
unsigned numOptionalUnwraps,
4001
4025
ConstraintLocatorBuilder locator);
4002
4026
@@ -4021,7 +4045,7 @@ class ConstraintSystem {
4021
4045
// / call.
4022
4046
// /
4023
4047
// / \returns \c true if an error was encountered, \c false otherwise.
4024
- bool simplifyAppliedOverloads (Type fnType, const FunctionType *argFnType,
4048
+ bool simplifyAppliedOverloads (Type fnType, FunctionType *argFnType,
4025
4049
ConstraintLocatorBuilder locator);
4026
4050
4027
4051
// / Retrieve the type that will be used when matching the given overload.
@@ -5334,11 +5358,12 @@ class DisjunctionChoice {
5334
5358
5335
5359
bool isBeginningOfPartition () const { return IsBeginningOfPartition; }
5336
5360
5337
- // FIXME: Both of the accessors below are required to support
5361
+ // FIXME: All three of the accessors below are required to support
5338
5362
// performance optimization hacks in constraint solver.
5339
5363
5340
5364
bool isGenericOperator () const ;
5341
5365
bool isSymmetricOperator () const ;
5366
+ bool isUnaryOperator () const ;
5342
5367
5343
5368
void print (llvm::raw_ostream &Out, SourceManager *SM) const {
5344
5369
Out << " disjunction choice " ;
0 commit comments