Skip to content

Commit a969486

Browse files
committed
swift-module-digester: diagnose added associated types as ABI breakages even they have default type.
1 parent 8e81b59 commit a969486

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ 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
7273
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
7374
cake2: Func RequiementChanges.addedFunc() has been added as a protocol requirement
7475
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ 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
5051
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
5152
cake2: Func RequiementChanges.addedFunc() has been added as a protocol requirement
5253
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -942,14 +942,7 @@ 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()) {
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)
945+
if (D->isProtocolRequirement() && !D->isOverriding()) {
953946
Ctx.getDiags().diagnose(SourceLoc(), diag::protocol_req_added,
954947
D->getScreenInfo());
955948
}

0 commit comments

Comments
 (0)