Skip to content

Commit

Permalink
Merge pull request #24151 from AnthonyLatsis/cleanup-func-subscript-v…
Browse files Browse the repository at this point in the history
…alidation

TypeChecker: consolidate func & subscript signature validation
  • Loading branch information
slavapestov authored Apr 21, 2019
2 parents ec1c2ee + 00e6ae1 commit 8ec0e39
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 299 deletions.
17 changes: 4 additions & 13 deletions lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4009,16 +4009,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
}
}

// If we have generic parameters, check the generic signature now.
if (FD->getGenericParams() || !isa<AccessorDecl>(FD)) {
validateGenericFuncSignature(FD);
} else {
// We've inherited all of the type information already.
FD->setGenericEnvironment(
FD->getDeclContext()->getGenericEnvironmentOfContext());

FD->computeType();
}
validateGenericFuncOrSubscriptSignature(FD, FD, FD);

if (!isa<AccessorDecl>(FD) || cast<AccessorDecl>(FD)->isGetter()) {
auto *TyR = getTypeLocForFunctionResult(FD).getTypeRepr();
Expand Down Expand Up @@ -4132,7 +4123,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
}
}

validateGenericFuncSignature(CD);
validateGenericFuncOrSubscriptSignature(CD, CD, CD);

// We want the constructor to be available for name lookup as soon
// as it has a valid interface type.
Expand All @@ -4156,7 +4147,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {

checkDeclAttributesEarly(DD);

validateGenericFuncSignature(DD);
validateGenericFuncOrSubscriptSignature(DD, DD, DD);

DD->setSignatureIsValidated();

Expand All @@ -4169,7 +4160,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {

DeclValidationRAII IBV(SD);

validateGenericSubscriptSignature(SD);
validateGenericFuncOrSubscriptSignature(SD, SD, SD);

SD->setSignatureIsValidated();

Expand Down
Loading

0 comments on commit 8ec0e39

Please sign in to comment.