Skip to content

Commit 1845ed6

Browse files
authored
Merge pull request #17837 from nkcsgexi/ownership-equi
2 parents b8ed087 + c974645 commit 1845ed6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2387,13 +2387,25 @@ static void detectRename(NodePtr L, NodePtr R) {
23872387
}
23882388
}
23892389

2390+
static bool isOwnershipEquivalent(ReferenceOwnership Left,
2391+
ReferenceOwnership Right) {
2392+
if (Left == Right)
2393+
return true;
2394+
if (Left == ReferenceOwnership::Unowned && Right == ReferenceOwnership::Weak)
2395+
return true;
2396+
if (Left == ReferenceOwnership::Weak && Right == ReferenceOwnership::Unowned)
2397+
return true;
2398+
return false;
2399+
}
2400+
23902401
static void detectDeclChange(NodePtr L, NodePtr R) {
23912402
assert(L->getKind() == R->getKind());
23922403
if (auto LD = dyn_cast<SDKNodeDecl>(L)) {
23932404
auto *RD = R->getAs<SDKNodeDecl>();
23942405
if (LD->isStatic() ^ RD->isStatic())
23952406
L->annotate(NodeAnnotation::StaticChange);
2396-
if (LD->getReferenceOwnership() != RD->getReferenceOwnership())
2407+
if (!isOwnershipEquivalent(LD->getReferenceOwnership(),
2408+
RD->getReferenceOwnership()))
23972409
L->annotate(NodeAnnotation::OwnershipChange);
23982410
detectRename(L, R);
23992411
}

0 commit comments

Comments
 (0)