Skip to content

Commit 86d557f

Browse files
committed
Sema: Use GenericSignature::requirementsNotSatisfiedBy() when checking autodiff attributes
1 parent 8fc0af3 commit 86d557f

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4380,14 +4380,8 @@ static bool typeCheckDerivativeAttr(ASTContext &Ctx, Decl *D,
43804380
// requirements are not satisfied.
43814381
if (!source)
43824382
return false;
4383-
// Check if target's requirements are satisfied by source.
4384-
// Use invalid 'SourceLoc's to suppress diagnostics.
4385-
return TypeChecker::checkGenericArguments(
4386-
derivative, SourceLoc(), SourceLoc(), Type(),
4387-
source->getGenericParams(), target->getRequirements(),
4388-
[](SubstitutableType *dependentType) {
4389-
return Type(dependentType);
4390-
}) == RequirementCheckResult::Success;
4383+
4384+
return target->requirementsNotSatisfiedBy(source).empty();
43914385
};
43924386

43934387
auto isValidOriginal = [&](AbstractFunctionDecl *originalCandidate) {
@@ -4914,17 +4908,8 @@ void AttributeChecker::visitTransposeAttr(TransposeAttr *attr) {
49144908
// requirements are not satisfied.
49154909
if (!source)
49164910
return false;
4917-
// Check if target's requirements are satisfied by source.
4918-
// Use invalid 'SourceLoc's to suppress diagnostics.
4919-
// Diagnostics should not be emitted because this function is used to
4920-
// check candidates; if no candidates match, a separate diagnostic will
4921-
// be produced.
4922-
return TypeChecker::checkGenericArguments(
4923-
transpose, SourceLoc(), SourceLoc(), Type(),
4924-
source->getGenericParams(), target->getRequirements(),
4925-
[](SubstitutableType *dependentType) {
4926-
return Type(dependentType);
4927-
}) == RequirementCheckResult::Success;
4911+
4912+
return target->requirementsNotSatisfiedBy(source).empty();
49284913
};
49294914

49304915
auto isValidOriginal = [&](AbstractFunctionDecl *originalCandidate) {

0 commit comments

Comments
 (0)