Skip to content

Commit b956043

Browse files
authored
Merge pull request #19669 from nkcsgexi/address-slava-commets
swift-module-digester: Address Slava's comments
2 parents e08b2d8 + 9364415 commit b956043

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ERROR(decl_reorder,none,"%0 in a non-resilient type changes position from %1 to
5858

5959
ERROR(decl_added,none,"%0 is added to a non-resilient type", (StringRef))
6060

61-
ERROR(decl_has_fixed_order_change,none,"%0 is %select{now|no longer}1 a property with fixed layout order", (StringRef, bool))
61+
ERROR(decl_has_fixed_order_change,none,"%0 is %select{now|no longer}1 a stored property", (StringRef, bool))
6262

6363
ERROR(default_arg_removed,none,"%0 has removed default argument from %1", (StringRef, StringRef))
6464

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ cake1: EnumElement FrozenKind.Fixed in a non-resilient type changes position fro
5454
cake1: EnumElement FrozenKind.Rigid in a non-resilient type changes position from 2 to 1
5555
cake1: Var fixedLayoutStruct.a in a non-resilient type changes position from 1 to 0
5656
cake1: Var fixedLayoutStruct.b in a non-resilient type changes position from 0 to 1
57-
cake1: Var fixedLayoutStruct2.BecomeFixedBinaryOrder is now a property with fixed layout order
58-
cake1: Var fixedLayoutStruct2.NoLongerWithFixedBinaryOrder is no longer a property with fixed layout order
57+
cake1: Var fixedLayoutStruct2.BecomeFixedBinaryOrder is now a stored property
58+
cake1: Var fixedLayoutStruct2.NoLongerWithFixedBinaryOrder is no longer a stored property
5959
cake2: EnumElement FrozenKind.AddedCase is added to a non-resilient type
6060
cake2: Var fixedLayoutStruct.c is added to a non-resilient type
6161
cake2: Var fixedLayoutStruct.lazy_d.storage is added to a non-resilient type
@@ -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)