ABI checker: adding protocol requirement with default implementation should not be flagged as breakage

rdar://98583968
This commit is contained in:
Xi Ge
2022-08-15 11:39:12 -07:00
parent feecc515d2
commit 227c2ba9a1
2 changed files with 33 additions and 0 deletions

View File

@@ -691,6 +691,21 @@ public:
// to the allowlist.
ShouldComplain = false;
}
if (ShouldComplain) {
// Providing a default implementation via a protocol extension for
// a protocol requirement is both ABI and API safe.
if (auto *PD = dyn_cast<SDKNodeDecl>(D->getParent())) {
for (auto *SIB: PD->getChildren()) {
if (auto *SIBD = dyn_cast<SDKNodeDecl>(SIB)) {
if (SIBD->isFromExtension() &&
SIBD->getPrintedName() == D->getPrintedName()) {
ShouldComplain = false;
break;
}
}
}
}
}
if (ShouldComplain)
D->emitDiag(D->getLoc(), diag::protocol_req_added);
}