mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
api-digester: diagnose adding conformances to existing protocols. rdar://48131686
This commit is contained in:
@@ -951,6 +951,8 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
|
||||
SDKContext &Ctx;
|
||||
UpdatedNodesMap &UpdateMap;
|
||||
llvm::StringSet<> ProtocolReqWhitelist;
|
||||
SDKNodeRoot *LeftRoot;
|
||||
SDKNodeRoot *RightRoot;
|
||||
|
||||
static void printSpaces(llvm::raw_ostream &OS, SDKNode *N) {
|
||||
assert(N);
|
||||
@@ -1028,6 +1030,12 @@ public:
|
||||
auto *TD = Conf->getNominalTypeDecl();
|
||||
if (TD->isProtocol()) {
|
||||
TD->emitDiag(diag::conformance_added, Conf->getName());
|
||||
} else {
|
||||
// Adding conformance to an existing type can be ABI breaking.
|
||||
if (Ctx.checkingABI() &&
|
||||
!LeftRoot->getDescendantsByUsr(Conf->getUsr()).empty()) {
|
||||
TD->emitDiag(diag::existing_conformance_added, Conf->getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,6 +1136,8 @@ public:
|
||||
}
|
||||
|
||||
void pass(NodePtr Left, NodePtr Right) override {
|
||||
LeftRoot = Left->getAs<SDKNodeRoot>();
|
||||
RightRoot = Right->getAs<SDKNodeRoot>();
|
||||
foundMatch(Left, Right, NodeMatchReason::Root);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user