Skip to content

Commit 784cb9e

Browse files
committed
Revert "swift-module-digester: diagnose added associated types as ABI breakages even they have default type."
1 parent c22711a commit 784cb9e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

test/api-digester/Outputs/Cake-abi.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ cake1: Struct fixedLayoutStruct has removed conformance to P1
6969

7070
/* Protocol Requirement Change */
7171
cake1: AssociatedType AssociatedTypePro.T1 has removed default type Int
72-
cake2: AssociatedType RequiementChanges.addedTypeWithDefault has been added as a protocol requirement
7372
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
7473
cake2: Func RequiementChanges.addedFunc() has been added as a protocol requirement
7574
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement

test/api-digester/Outputs/Cake.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ cake1: Struct fixedLayoutStruct has removed conformance to P1
4747

4848
/* Protocol Requirement Change */
4949
cake1: AssociatedType AssociatedTypePro.T1 has removed default type Int
50-
cake2: AssociatedType RequiementChanges.addedTypeWithDefault has been added as a protocol requirement
5150
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
5251
cake2: Func RequiementChanges.addedFunc() has been added as a protocol requirement
5352
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,14 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
942942
}
943943
// Complain about added protocol requirements
944944
if (auto *D = dyn_cast<SDKNodeDecl>(Right)) {
945-
if (D->isProtocolRequirement() && !D->isOverriding()) {
945+
if (D->isProtocolRequirement()) {
946+
bool ShouldComplain = !D->isOverriding();
947+
// We should allow added associated types with default.
948+
if (auto ATD = dyn_cast<SDKNodeDeclAssociatedType>(D)) {
949+
if (ATD->getDefault())
950+
ShouldComplain = false;
951+
}
952+
if (ShouldComplain)
946953
Ctx.getDiags().diagnose(SourceLoc(), diag::protocol_req_added,
947954
D->getScreenInfo());
948955
}

0 commit comments

Comments
 (0)