Skip to content

Commit 46b5af5

Browse files
authored
Merge pull request swiftlang#25104 from nkcsgexi/synthesized-type-as-extension
ABI checker: diagnose the missing of @available attributes for added ABIs
2 parents 6da1be5 + de1718e commit 46b5af5

15 files changed

+112
-14
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ ERROR(type_witness_change,none,"%0 has type witness type for %1 changing from %2
9696

9797
ERROR(decl_new_witness_table_entry,none,"%0 now requires %select{|no}1 new witness table entry", (StringRef, bool))
9898

99+
ERROR(new_decl_without_intro,none,"%0 is a new API without @available attribute", (StringRef))
100+
99101
#ifndef DIAG_NO_UNDEF
100102
# if defined(DIAG)
101103
# undef DIAG

test/api-digester/Inputs/cake1.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,7 @@ public protocol HasMutatingMethodClone: HasMutatingMethod {
168168
mutating func foo()
169169
var bar: Int { mutating get }
170170
}
171+
172+
public extension Int {
173+
public func IntEnhancer() {}
174+
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cake1: Protocol P3 has generic signature change from <τ_0_0 : cake.P1, τ_0_0 :
66
/* RawRepresentable Changes */
77

88
/* Removed Decls */
9+
Swift: Extension Int has been removed
910
cake1: Accessor GlobalVarChangedToLet.Set() has been removed
1011
cake1: Accessor RemoveSetters.Value.Set() has been removed
1112
cake1: AssociatedType RequiementChanges.removedType has been removed
@@ -56,6 +57,20 @@ cake1: Var C1.CIIns1 changes from weak to strong
5657
cake1: Var C1.CIIns2 changes from strong to weak
5758
cake1: Var GlobalLetChangedToVar changes from let to var
5859
cake1: Var GlobalVarChangedToLet changes from var to let
60+
cake2: Accessor GlobalLetChangedToVar.Set() is a new API without @available attribute
61+
cake2: Accessor fixedLayoutStruct2.BecomeFixedBinaryOrder.Set() is a new API without @available attribute
62+
cake2: AssociatedType RequiementChanges.addedTypeWithDefault is a new API without @available attribute
63+
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault is a new API without @available attribute
64+
cake2: Class C0 is a new API without @available attribute
65+
cake2: Class C8 is a new API without @available attribute
66+
cake2: Constructor C1.init(_:) is a new API without @available attribute
67+
cake2: EnumElement FrozenKind.AddedCase is a new API without @available attribute
68+
cake2: Func RequiementChanges.addedFunc() is a new API without @available attribute
69+
cake2: Func fixedLayoutStruct.OKChange() is a new API without @available attribute
70+
cake2: Protocol P4 is a new API without @available attribute
71+
cake2: Var RequiementChanges.addedVar is a new API without @available attribute
72+
cake2: Var fixedLayoutStruct.$__lazy_storage_$_lazy_d is a new API without @available attribute
73+
cake2: Var fixedLayoutStruct.c is a new API without @available attribute
5974

6075
/* Fixed-layout Type changes */
6176
cake1: EnumElement FrozenKind.Fixed in a non-resilient type changes position from 1 to 2

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cake1: Protocol P3 has generic signature change from <Self : cake.P1, Self : cak
66
/* RawRepresentable Changes */
77

88
/* Removed Decls */
9+
Swift: Extension Int has been removed
910
cake1: Accessor GlobalVarChangedToLet.Set() has been removed
1011
cake1: Accessor RemoveSetters.Value.Set() has been removed
1112
cake1: AssociatedType RequiementChanges.removedType has been removed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,10 @@
10351035
"moduleName": "cake",
10361036
"genericSig": "<τ_0_0 where τ_0_0 : PSuper>",
10371037
"isABIPlaceholder": true,
1038+
"intro_Macosx": "9999",
1039+
"intro_iOS": "9999",
1040+
"intro_tvOS": "9999",
1041+
"intro_watchOS": "9999",
10381042
"funcSelfKind": "NonMutating"
10391043
}
10401044
],

test/api-digester/Outputs/cake.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,10 @@
982982
"moduleName": "cake",
983983
"genericSig": "<Self where Self : PSuper>",
984984
"isABIPlaceholder": true,
985+
"intro_Macosx": "9999",
986+
"intro_iOS": "9999",
987+
"intro_tvOS": "9999",
988+
"intro_watchOS": "9999",
985989
"funcSelfKind": "NonMutating"
986990
}
987991
],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Func _collectReferencesInsideObject(_:) is a new API without @available attribute
2+
Func _loadDestroyTLSCounter() is a new API without @available attribute
3+
Protocol _RuntimeFunctionCountersStats is a new API without @available attribute
4+
Struct _GlobalRuntimeFunctionCountersState is a new API without @available attribute
5+
Struct _ObjectRuntimeFunctionCountersState is a new API without @available attribute
6+
Struct _RuntimeFunctionCounters is a new API without @available attribute
7+
Func _measureRuntimeFunctionCountersDiffs(objects:_:) is a new API without @available attribute

test/api-digester/Outputs/stability-stdlib-abi.swift.expected

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// The init(signOf:magnitudeOf:) blames are false positives. They are not new APIs.
2+
Constructor Double.init(signOf:magnitudeOf:) is a new API without @available attribute
3+
Constructor Float.init(signOf:magnitudeOf:) is a new API without @available attribute
4+
Constructor Float80.init(signOf:magnitudeOf:) is a new API without @available attribute
5+
6+
Constructor __RawDictionaryStorage.init(coder:) is a new API without @available attribute
7+
Constructor __RawSetStorage.init(coder:) is a new API without @available attribute
8+
Constructor __SwiftNativeNSData.init(coder:) is a new API without @available attribute
9+
Constructor __SwiftNativeNSDictionary.init(coder:) is a new API without @available attribute
10+
Constructor __SwiftNativeNSSet.init(coder:) is a new API without @available attribute
11+
12+
Func _cos(_:) has been removed
13+
Func _exp(_:) has been removed
14+
Func _exp2(_:) has been removed
15+
16+
Func _log(_:) has been removed
17+
Func _log10(_:) has been removed
18+
Func _log2(_:) has been removed
19+
20+
Func _nearbyint(_:) has been removed
21+
Func _rint(_:) has been removed
22+
Func _sin(_:) has been removed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// REQUIRES: OS=macosx
2+
// REQUIRES: swift_stdlib_asserts
3+
// RUN: %empty-directory(%t.tmp)
4+
// mkdir %t.tmp/module-cache && mkdir %t.tmp/dummy.sdk
5+
// RUN: %api-digester -dump-sdk -module Swift -o %t.tmp/current-stdlib.json -module-cache-path %t.tmp/module-cache -sdk %t.tmp/dummy.sdk -abi -avoid-location
6+
// RUN: %api-digester -diagnose-sdk -input-paths %S/Inputs/stdlib-stable-abi.json -input-paths %t.tmp/current-stdlib.json -abi -o %t.tmp/changes.txt -v
7+
// RUN: %clang -E -P -x c %S/Outputs/stability-stdlib-abi.without.asserts.swift.expected -o - > %t.tmp/stability-stdlib-abi.swift.expected
8+
// RUN: %clang -E -P -x c %S/Outputs/stability-stdlib-abi.asserts.additional.swift.expected -o - >> %t.tmp/stability-stdlib-abi.swift.expected
9+
// RUN: %clang -E -P -x c %t.tmp/stability-stdlib-abi.swift.expected -o - | sed '/^\s*$/d' | sort > %t.tmp/stability-stdlib-abi.swift.expected.sorted
10+
// RUN: %clang -E -P -x c %t.tmp/changes.txt -o - | sed '/^\s*$/d' | sort > %t.tmp/changes.txt.tmp
11+
// RUN: diff -u %t.tmp/stability-stdlib-abi.swift.expected.sorted %t.tmp/changes.txt.tmp
12+
13+
// The digester can incorrectly register a generic signature change when
14+
// declarations are shuffled. rdar://problem/46618883
15+
// UNSUPPORTED: swift_evolve

0 commit comments

Comments
 (0)