Skip to content

Commit ed13a2f

Browse files
committed
ABI checker: require explicit @available attributes for new APIs
Before this change, the ABI checker didn't complain about missing @available attributes on new APIs if the enclosing scopes of new APIs have availability information. Instead, we should require explicit @available attributes for new APIs to prevent them inheriting wrong availability information from a preexisting scope. rdar://81719628
1 parent b26c15d commit ed13a2f

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ StringRef SDKContext::getPlatformIntroVersion(Decl *D, PlatformKind Kind) {
12511251
}
12521252
}
12531253
}
1254-
return getPlatformIntroVersion(D->getDeclContext()->getAsDecl(), Kind);
1254+
return StringRef();
12551255
}
12561256

12571257
StringRef SDKContext::getLanguageIntroVersion(Decl *D) {

stdlib/public/core/Policy.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extension Never: Equatable, Comparable, Hashable {}
3636

3737
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
3838
extension Never: Identifiable {
39+
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
3940
public var id: Never {
4041
switch self {}
4142
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,19 @@ cake: Accessor fixedLayoutStruct2.BecomeFixedBinaryOrder.Modify() is a new API w
5353
cake: Accessor fixedLayoutStruct2.BecomeFixedBinaryOrder.Set() is a new API without @available attribute
5454
cake: Class C0 is a new API without @available attribute
5555
cake: Class C8 is a new API without @available attribute
56+
cake: Constructor AddingNewDesignatedInit.init(_:) is a new API without @available attribute
5657
cake: Constructor C1.init(_:) is a new API without @available attribute
5758
cake: Constructor ClassWithMissingDesignatedInits.init() is a new API without @available attribute
5859
cake: Constructor SubclassWithMissingDesignatedInits.init() is a new API without @available attribute
5960
cake: Enum IceKind is now without @frozen
6061
cake: EnumElement FrozenKind.AddedCase is a new API without @available attribute
62+
cake: EnumElement FutureKind.FineToAdd is a new API without @available attribute
6163
cake: Func C1.foo1() is now not static
6264
cake: Func FinalFuncContainer.NewFinalFunc() is now with final
6365
cake: Func FinalFuncContainer.NoLongerFinalFunc() is now without final
6466
cake: Func Float.floatHigher() is a new API without @available attribute
67+
cake: Func FutureKind.==(_:_:) is a new API without @available attribute
68+
cake: Func FutureKind.hash(into:) is a new API without @available attribute
6569
cake: Func HasMutatingMethodClone.foo() has self access kind changing from Mutating to NonMutating
6670
cake: Func RequiementChanges.addedFunc() is a new API without @available attribute
6771
cake: Func S1.foo1() has self access kind changing from NonMutating to Mutating
@@ -72,6 +76,7 @@ cake: Protocol P4 is a new API without @available attribute
7276
cake: Struct C6 is now with @frozen
7377
cake: Var C1.CIIns1 changes from weak to strong
7478
cake: Var C1.CIIns2 changes from strong to weak
79+
cake: Var FutureKind.hashValue is a new API without @available attribute
7580
cake: Var RequiementChanges.addedVar is a new API without @available attribute
7681
cake: Var fixedLayoutStruct.$__lazy_storage_$_lazy_d is a new API without @available attribute
7782
cake: Var fixedLayoutStruct.c is a new API without @available attribute

test/api-digester/Outputs/cake-abi.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,10 +1248,6 @@
12481248
"moduleName": "cake",
12491249
"genericSig": "<τ_0_0 where τ_0_0 : cake.PSuper>",
12501250
"sugared_genericSig": "<Self where Self : cake.PSuper>",
1251-
"intro_Macosx": "10.15",
1252-
"intro_iOS": "13",
1253-
"intro_tvOS": "13",
1254-
"intro_watchOS": "6",
12551251
"funcSelfKind": "NonMutating"
12561252
}
12571253
],

test/api-digester/Outputs/cake.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,10 +1135,6 @@
11351135
"usr": "s:4cake6PSuperPAAE9futureFooyyF",
11361136
"moduleName": "cake",
11371137
"genericSig": "<Self where Self : cake.PSuper>",
1138-
"intro_Macosx": "10.15",
1139-
"intro_iOS": "13",
1140-
"intro_tvOS": "13",
1141-
"intro_watchOS": "6",
11421138
"funcSelfKind": "NonMutating"
11431139
}
11441140
],

0 commit comments

Comments
 (0)