diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp index 2375ced2375b6..3ed147990f6d5 100644 --- a/lib/AST/ASTVerifier.cpp +++ b/lib/AST/ASTVerifier.cpp @@ -2715,6 +2715,37 @@ class Verifier : public ASTWalker { verifyCheckedBase(nominal); } + void verifyCheckedAlways(GenericTypeParamDecl *GTPD) { + PrettyStackTraceDecl debugStack("verifying GenericTypeParamDecl", GTPD); + + const DeclContext *DC = GTPD->getDeclContext(); + if (!GTPD->getDeclContext()->isInnermostContextGeneric()) { + Out << "DeclContext of GenericTypeParamDecl does not have " + "generic params"; + abort(); + } + + GenericParamList *paramList = + static_cast(DC)->getGenericParams(); + if (!paramList) { + Out << "DeclContext of GenericTypeParamDecl does not have " + "generic params"; + abort(); + } + + if (paramList->size() <= GTPD->getIndex() || + paramList->getParams()[GTPD->getIndex()] != GTPD) { + Out << "GenericTypeParamDecl has incorrect index"; + abort(); + } + if (paramList->getDepth() != GTPD->getDepth()) { + Out << "GenericTypeParamDecl has incorrect depth"; + abort(); + } + + verifyCheckedBase(GTPD); + } + void verifyChecked(ExtensionDecl *ext) { // Make sure that the protocol conformances are complete. for (auto conformance : ext->getLocalConformances()) {