@@ -47,6 +47,10 @@ Constraint::Constraint(ConstraintKind kind, ArrayRef<Constraint *> constraints,
4747 getTypeVariablesBuffer ().begin ());
4848}
4949
50+ static bool isAdmissibleType (Type type) {
51+ return !type->hasUnboundGenericType () && !type->hasTypeParameter ();
52+ }
53+
5054Constraint::Constraint (ConstraintKind Kind, Type First, Type Second,
5155 ConstraintLocator *locator,
5256 SmallPtrSetImpl<TypeVariableType *> &typeVars)
@@ -55,6 +59,9 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
5559 IsFavored(false ), IsIsolated(false ),
5660 NumTypeVariables(typeVars.size()), Types{First, Second, Type ()},
5761 Locator (locator) {
62+ ASSERT (isAdmissibleType (First));
63+ ASSERT (isAdmissibleType (Second));
64+
5865 switch (Kind) {
5966 case ConstraintKind::Bind:
6067 case ConstraintKind::Equal:
@@ -84,11 +91,9 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
8491 case ConstraintKind::SameShape:
8592 case ConstraintKind::MaterializePackExpansion:
8693 case ConstraintKind::LValueObject:
87- assert (!First.isNull ());
88- assert (!Second.isNull ());
8994 break ;
9095 case ConstraintKind::DynamicCallableApplicableFunction:
91- assert (First->is <FunctionType>()
96+ ASSERT (First->is <FunctionType>()
9297 && " The left-hand side type should be a function type" );
9398 break ;
9499
@@ -99,8 +104,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,
99104
100105 case ConstraintKind::Defaultable:
101106 case ConstraintKind::FallbackType:
102- assert (!First.isNull ());
103- assert (!Second.isNull ());
104107 break ;
105108
106109 case ConstraintKind::BindOverload:
@@ -136,6 +139,10 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second, Type Third,
136139 IsFavored(false ), IsIsolated(false ),
137140 NumTypeVariables(typeVars.size()), Types{First, Second, Third},
138141 Locator (locator) {
142+ ASSERT (isAdmissibleType (First));
143+ ASSERT (isAdmissibleType (Second));
144+ ASSERT (isAdmissibleType (Third));
145+
139146 switch (Kind) {
140147 case ConstraintKind::Bind:
141148 case ConstraintKind::Equal:
@@ -180,9 +187,6 @@ Constraint::Constraint(ConstraintKind Kind, Type First, Type Second, Type Third,
180187
181188 case ConstraintKind::KeyPath:
182189 case ConstraintKind::KeyPathApplication:
183- assert (!First.isNull ());
184- assert (!Second.isNull ());
185- assert (!Third.isNull ());
186190 break ;
187191 }
188192
@@ -256,8 +260,8 @@ Constraint::Constraint(ConstraintKind kind,
256260 RememberChoice(false ), IsFavored(false ), IsIsolated(false ),
257261 NumTypeVariables(typeVars.size()), Types{first, second, Type ()},
258262 Locator (locator) {
259- assert (!first. isNull ( ));
260- assert (!second. isNull ( ));
263+ ASSERT ( isAdmissibleType (first ));
264+ ASSERT ( isAdmissibleType (second ));
261265 std::copy (typeVars.begin (), typeVars.end (), getTypeVariablesBuffer ().begin ());
262266}
263267
@@ -269,8 +273,8 @@ Constraint::Constraint(ConstraintKind kind, ConstraintFix *fix, Type first,
269273 IsFavored(false ), IsIsolated(false ),
270274 NumTypeVariables(typeVars.size()), Types{first, second, Type ()},
271275 Locator (locator) {
272- assert (!first. isNull ( ));
273- assert (!second. isNull ( ));
276+ ASSERT ( isAdmissibleType (first ));
277+ ASSERT ( isAdmissibleType (second ));
274278 std::copy (typeVars.begin (), typeVars.end (), getTypeVariablesBuffer ().begin ());
275279 if (fix)
276280 *getTrailingObjects<ConstraintFix *>() = fix;
@@ -297,8 +301,8 @@ Constraint::Constraint(FunctionType *appliedFn, Type calleeType,
297301 HasRestriction(false ), IsActive(false ), IsDisabled(false ),
298302 IsDisabledForPerformance(false ), RememberChoice(false ), IsFavored(false ),
299303 IsIsolated(false ), NumTypeVariables(typeVars.size()), Locator(locator) {
300- assert ( appliedFn);
301- assert ( calleeType);
304+ ASSERT ( isAdmissibleType ( appliedFn) );
305+ ASSERT ( isAdmissibleType ( calleeType) );
302306 assert (trailingClosureMatching >= 0 && trailingClosureMatching <= 2 );
303307 assert (useDC);
304308
0 commit comments