Skip to content

Commit a74570b

Browse files
committed
api-digester: Support old name for @backDeployed
Swift 5.7’s API digester supported the unofficial @_backDeploy attribute, writing it to digests under the name “BackDeploy”, but by the time it the proposal was accepted, the spelling in source code was @backDeployed and the spelling in digests became “BackDeployed”. Add a special case to the new digester to accept the old spelling. This should fix an issue seen in Swift CI where the WholeSDK API digester test couldn’t process the StoreKit framework.
1 parent 1f7f6c6 commit a74570b

File tree

7 files changed

+22
-3
lines changed

7 files changed

+22
-3
lines changed

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,10 @@ SDKNode* SDKNode::constructSDKNode(SDKContext &Ctx,
739739
auto Result = llvm::StringSwitch<DeclAttrKind>(GetScalarString(&N))
740740
#define DECL_ATTR(_, NAME, ...) .Case(#NAME, DeclAttrKind::DAK_##NAME)
741741
#include "swift/AST/Attr.def"
742+
// BackDeployAttr was renamed to BackDeployedAttr, but not before a
743+
// compiler shipped which used the old name in digests. Make the old
744+
// name equivalent to the new one.
745+
.Case("BackDeploy", DeclAttrKind::DAK_BackDeployed)
742746
.Default(DeclAttrKind::DAK_Count);
743747
if (Result == DAK_Count)
744748
Ctx.diagnose(&N, diag::sdk_node_unrecognized_decl_attr_kind,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public class Zoo {
214214
public func getCurrentAnimalInlinable() -> [some Animal] {
215215
return [Cat()]
216216
}
217+
@backDeployed(before: iOS 14.0, OSX 10.16, tvOS 14.0, watchOS 7.0)
218+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
219+
public final func getCurrentAnimalBackDeployed() -> [Cat] {
220+
return [Cat()]
221+
}
217222
}
218223

219224
public func returnFunctionTypeOwnershipChange() -> (C1) -> () { return { _ in } }

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ public class Zoo {
227227
public func getCurrentAnimalInlinable() -> [some Animal] {
228228
return [Dog()]
229229
}
230+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
231+
public final func getCurrentAnimalBackDeployed() -> [Cat] {
232+
return [Cat()]
233+
}
230234
}
231235

232236
public func returnFunctionTypeOwnershipChange() -> (__owned C1) -> () { return { _ in } }

test/api-digester/Inputs/diagnostics-compare.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"children": [
66
{
77
"kind": "Function",
8-
"declAttributes": ["Available", "ObjC"],
8+
"declAttributes": ["Available", "ObjC", "BackDeployed"],
99
"declKind": "Func",
1010
"name": "foo",
1111
"children": [],

test/api-digester/Inputs/diagnostics.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"children": [
77
{
88
"kind": "Zyzyx",
9-
"typeAttributes": ["autoclosure", "fnord", "inout", "Available"],
9+
"typeAttributes": ["autoclosure", "fnord", "inout", "Available", "BackDeploy"],
1010
"declAttributes": ["Available", "Fnord", "ObjC", "inout"],
1111
"declKind": "Subroutine"
1212
},
1313
{
1414
"kind": "Function",
15-
"declAttributes": ["Available", "Fnord", "ObjC", "inout"],
15+
"declAttributes": ["Available", "Fnord", "ObjC", "inout", "BackDeploy"],
1616
"declKind": "Func",
1717
"name": "foo",
1818
"children": [],

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ cake: Func C1.foo1() is now not static
4343
cake: Func HasMutatingMethodClone.foo() has self access kind changing from Mutating to NonMutating
4444
cake: Func S1.foo1() has self access kind changing from NonMutating to Mutating
4545
cake: Func S1.foo3() is now static
46+
cake: Func Zoo.getCurrentAnimalBackDeployed() is now without @backDeployed
4647
cake: Var C1.CIIns1 changes from weak to strong
4748
cake: Var C1.CIIns2 changes from strong to weak
4849
cake: EnumElement FrozenKind.AddedCase has been added as a new enum case

test/api-digester/diagnostics.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@
2020
// Make sure we don't try to output a result:
2121
// NEGATIVE-NOT: "kind": "Root",
2222

23+
// Older versions of the compiler used 'BackDeploy' for @_backDeploy. We now use
24+
// 'BackDeployed', but we should still support the old name.
25+
// NEGATIVE-NOT: error: unrecognized declaration attribute 'BackDeploy' in SDK node
26+
// NEGATIVE-NOT: is now without @backDeployed
27+
2328
// Should not have any errors in the diagnostics-compare file.
2429
// NEGATIVE-NOT: diagnostics-compare.json:{{.*}}: error:

0 commit comments

Comments
 (0)