@@ -47,6 +47,10 @@ Constraint::Constraint(ConstraintKind kind, ArrayRef<Constraint *> constraints,
47
47
getTypeVariablesBuffer ().begin ());
48
48
}
49
49
50
+ static bool isAdmissibleType (Type type) {
51
+ return !type->hasUnboundGenericType () && !type->hasTypeParameter ();
52
+ }
53
+
50
54
Constraint::Constraint (ConstraintKind Kind, Type First, Type Second,
51
55
ConstraintLocator *locator,
52
56
SmallPtrSetImpl<TypeVariableType *> &typeVars)
@@ -55,6 +59,9 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
55
59
IsFavored(false ), IsIsolated(false ),
56
60
NumTypeVariables(typeVars.size()), Types{First, Second, Type ()},
57
61
Locator (locator) {
62
+ ASSERT (isAdmissibleType (First));
63
+ ASSERT (isAdmissibleType (Second));
64
+
58
65
switch (Kind) {
59
66
case ConstraintKind::Bind:
60
67
case ConstraintKind::Equal:
@@ -84,11 +91,9 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
84
91
case ConstraintKind::SameShape:
85
92
case ConstraintKind::MaterializePackExpansion:
86
93
case ConstraintKind::LValueObject:
87
- assert (!First.isNull ());
88
- assert (!Second.isNull ());
89
94
break ;
90
95
case ConstraintKind::DynamicCallableApplicableFunction:
91
- assert (First->is <FunctionType>()
96
+ ASSERT (First->is <FunctionType>()
92
97
&& " The left-hand side type should be a function type" );
93
98
break ;
94
99
@@ -99,8 +104,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
99
104
100
105
case ConstraintKind::Defaultable:
101
106
case ConstraintKind::FallbackType:
102
- assert (!First.isNull ());
103
- assert (!Second.isNull ());
104
107
break ;
105
108
106
109
case ConstraintKind::BindOverload:
@@ -136,6 +139,10 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second, Type Third,
136
139
IsFavored(false ), IsIsolated(false ),
137
140
NumTypeVariables(typeVars.size()), Types{First, Second, Third},
138
141
Locator (locator) {
142
+ ASSERT (isAdmissibleType (First));
143
+ ASSERT (isAdmissibleType (Second));
144
+ ASSERT (isAdmissibleType (Third));
145
+
139
146
switch (Kind) {
140
147
case ConstraintKind::Bind:
141
148
case ConstraintKind::Equal:
@@ -180,9 +187,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second, Type Third,
180
187
181
188
case ConstraintKind::KeyPath:
182
189
case ConstraintKind::KeyPathApplication:
183
- assert (!First.isNull ());
184
- assert (!Second.isNull ());
185
- assert (!Third.isNull ());
186
190
break ;
187
191
}
188
192
@@ -256,8 +260,8 @@ Constraint::Constraint(ConstraintKind kind,
256
260
RememberChoice(false ), IsFavored(false ), IsIsolated(false ),
257
261
NumTypeVariables(typeVars.size()), Types{first, second, Type ()},
258
262
Locator (locator) {
259
- assert (!first. isNull ( ));
260
- assert (!second. isNull ( ));
263
+ ASSERT ( isAdmissibleType (first ));
264
+ ASSERT ( isAdmissibleType (second ));
261
265
std::copy (typeVars.begin (), typeVars.end (), getTypeVariablesBuffer ().begin ());
262
266
}
263
267
@@ -269,8 +273,8 @@ Constraint::Constraint(ConstraintKind kind, ConstraintFix *fix, Type first,
269
273
IsFavored(false ), IsIsolated(false ),
270
274
NumTypeVariables(typeVars.size()), Types{first, second, Type ()},
271
275
Locator (locator) {
272
- assert (!first. isNull ( ));
273
- assert (!second. isNull ( ));
276
+ ASSERT ( isAdmissibleType (first ));
277
+ ASSERT ( isAdmissibleType (second ));
274
278
std::copy (typeVars.begin (), typeVars.end (), getTypeVariablesBuffer ().begin ());
275
279
if (fix)
276
280
*getTrailingObjects<ConstraintFix *>() = fix;
@@ -297,8 +301,8 @@ Constraint::Constraint(FunctionType *appliedFn, Type calleeType,
297
301
HasRestriction(false ), IsActive(false ), IsDisabled(false ),
298
302
IsDisabledForPerformance(false ), RememberChoice(false ), IsFavored(false ),
299
303
IsIsolated(false ), NumTypeVariables(typeVars.size()), Locator(locator) {
300
- assert ( appliedFn);
301
- assert ( calleeType);
304
+ ASSERT ( isAdmissibleType ( appliedFn) );
305
+ ASSERT ( isAdmissibleType ( calleeType) );
302
306
assert (trailingClosureMatching >= 0 && trailingClosureMatching <= 2 );
303
307
assert (useDC);
304
308
0 commit comments