Skip to content

Commit a79b1ff

Browse files
committed
ABI checker: report any printed name changes for type nodes
Under ABI checking mode where we don't have sugar types, any printed name changes of type nodes worth raising an alert. rdar://45567621
1 parent befffd9 commit a79b1ff

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed

test/api-digester/Inputs/cake_baseline/cake.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,3 +193,5 @@ public class Zoo {
193193
return Cat()
194194
}
195195
}
196+
197+
public func returnFunctionTypeOwnershipChange() -> (C1) -> () { return { _ in } }

test/api-digester/Inputs/cake_current/cake.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,5 @@ public class Zoo {
200200
return Dog()
201201
}
202202
}
203+
204+
public func returnFunctionTypeOwnershipChange() -> (__owned C1) -> () { return { _ in } }

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ cake: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1
4444
cake: Func Zoo.getCurrentAnimalInlinable() has return type change from Cat to Dog
4545
cake: Func ownershipChange(_:_:) has parameter 0 changing from InOut to Default
4646
cake: Func ownershipChange(_:_:) has parameter 1 changing from Shared to Owned
47+
cake: Func returnFunctionTypeOwnershipChange() has return type change from (C1) -> () to (__owned C1) -> ()
4748
cake: Var Zoo.current has declared type change from Cat to Dog
4849

4950
/* Decl Attribute changes */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Func BidirectionalCollection.difference(from:by:) has parameter 1 type change from (τ_0_0.Element, τ_1_0.Element) -> Bool to (τ_1_0.Element, τ_0_0.Element) -> Bool

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,14 @@ static bool isSDKNodeEqual(SDKContext &Ctx, const SDKNode &L, const SDKNode &R)
796796
return false;
797797
if (Left->getPrintedName() == Right->getPrintedName())
798798
return true;
799-
return Left->getName() == Right->getName() &&
800-
Left->hasSameChildren(*Right);
799+
if (Ctx.checkingABI()) {
800+
// For abi checking where we don't have sugar types at all, the printed
801+
// name difference is enough to indicate these two types differ.
802+
return false;
803+
} else {
804+
return Left->getName() == Right->getName() &&
805+
Left->hasSameChildren(*Right);
806+
}
801807
}
802808

803809
case SDKNodeKind::DeclFunction: {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ void swift::ide::api::SDKNodeType::diagnose(SDKNode *Right) {
927927
}
928928

929929
void swift::ide::api::SDKNodeTypeFunc::diagnose(SDKNode *Right) {
930-
SDKNode::diagnose(Right);
930+
SDKNodeType::diagnose(Right);
931931
auto *RT = dyn_cast<SDKNodeTypeFunc>(Right);
932932
if (!RT || !shouldDiagnoseType(this))
933933
return;

0 commit comments

Comments
 (0)