@@ -372,7 +372,7 @@ struct SemanticsDeclHeaderVisitor : public SemanticsDeclVisitorBase,
372
372
bool validateGenericConstraintSubType(
373
373
GenericTypeConstraintDecl* decl,
374
374
TypeExp type,
375
- bool diagnose );
375
+ DiagnosticSink* sink = nullptr );
376
376
377
377
void checkForwardReferencesInGenericConstraint(GenericTypeConstraintDecl* decl);
378
378
@@ -3256,7 +3256,7 @@ bool isProperConstraineeType(Type* type)
3256
3256
bool SemanticsDeclHeaderVisitor::validateGenericConstraintSubType(
3257
3257
GenericTypeConstraintDecl* decl,
3258
3258
TypeExp type,
3259
- bool diagnose )
3259
+ DiagnosticSink* sink )
3260
3260
{
3261
3261
// Validate that the sub type of a constraint is in valid form.
3262
3262
//
@@ -3276,8 +3276,8 @@ bool SemanticsDeclHeaderVisitor::validateGenericConstraintSubType(
3276
3276
auto dependentGeneric = getShared()->getDependentGenericParent(subDeclRef);
3277
3277
if (dependentGeneric.getDecl() != decl->parentDecl)
3278
3278
{
3279
- if (diagnose )
3280
- getSink() ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3279
+ if (sink )
3280
+ sink ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3281
3281
return false;
3282
3282
}
3283
3283
}
@@ -3296,8 +3296,8 @@ bool SemanticsDeclHeaderVisitor::validateGenericConstraintSubType(
3296
3296
auto lookupDeclRef = as<LookupDeclRef>(subDeclRef.declRefBase);
3297
3297
if (!lookupDeclRef)
3298
3298
{
3299
- if (diagnose )
3300
- getSink() ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3299
+ if (sink )
3300
+ sink ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3301
3301
return false;
3302
3302
}
3303
3303
@@ -3311,20 +3311,20 @@ bool SemanticsDeclHeaderVisitor::validateGenericConstraintSubType(
3311
3311
auto baseType = as<Type>(lookupDeclRef->getLookupSource());
3312
3312
if (!baseType)
3313
3313
{
3314
- if (diagnose )
3315
- getSink() ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3314
+ if (sink )
3315
+ sink ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3316
3316
return false;
3317
3317
}
3318
3318
type.type = baseType;
3319
- return validateGenericConstraintSubType(decl, type, diagnose );
3319
+ return validateGenericConstraintSubType(decl, type, sink );
3320
3320
}
3321
3321
}
3322
3322
if (!isProperConstraineeType(type.type))
3323
3323
{
3324
3324
// It is meaningless for certain types to be used in type constraints.
3325
3325
// For example, `IFoo<T>` should not appear as the left-hand-side of a generic constraint.
3326
- if (diagnose )
3327
- getSink() ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3326
+ if (sink )
3327
+ sink ->diagnose(type.exp, Diagnostics::invalidConstraintSubType, type);
3328
3328
return false;
3329
3329
}
3330
3330
return true;
@@ -3458,7 +3458,7 @@ void SemanticsDeclHeaderVisitor::visitGenericTypeConstraintDecl(GenericTypeConst
3458
3458
equalityCannon = checkGenericTypeEqualityCanonicalOrder(decl);
3459
3459
}
3460
3460
3461
- bool validSub = validateGenericConstraintSubType(decl, decl->sub, true );
3461
+ bool validSub = validateGenericConstraintSubType(decl, decl->sub, getSink() );
3462
3462
if (decl->isEqualityConstraint)
3463
3463
{
3464
3464
if (!validSub && !equalityCannon)
@@ -3493,8 +3493,8 @@ bool SemanticsDeclHeaderVisitor::checkGenericTypeEqualityCanonicalOrder(
3493
3493
{
3494
3494
auto compare = [&]() -> int
3495
3495
{
3496
- bool subOk = validateGenericConstraintSubType(decl, decl->sub, false );
3497
- bool supOk = validateGenericConstraintSubType(decl, decl->sup, false );
3496
+ bool subOk = validateGenericConstraintSubType(decl, decl->sub);
3497
+ bool supOk = validateGenericConstraintSubType(decl, decl->sup);
3498
3498
3499
3499
if (subOk != supOk) // Only one is qualified
3500
3500
{
0 commit comments