Skip to content

Commit 3b16f34

Browse files
authored
Merge pull request swiftlang#19508 from nkcsgexi/include-super-class
swift-module-digester: diagnose super class changes as API breakages
2 parents cc3db35 + 6e35290 commit 3b16f34

File tree

13 files changed

+153
-99
lines changed

13 files changed

+153
-99
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ ERROR(default_associated_type_removed,none,"%0 has removed default type %1", (St
6868

6969
ERROR(protocol_req_added,none,"%0 has been added as a protocol requirement", (StringRef))
7070

71+
ERROR(super_class_removed,none,"%0 has removed its super class %1", (StringRef, StringRef))
72+
73+
ERROR(super_class_changed,none,"%0 has changed its super class from %1 to %2", (StringRef, StringRef, StringRef))
74+
7175
#ifndef DIAG_NO_UNDEF
7276
# if defined(DIAG)
7377
# undef DIAG

include/swift/IDE/DigesterEnums.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ KEY(declAttributes)
109109
KEY(declKind)
110110
KEY(ownership)
111111
KEY(superclassUsr)
112+
KEY(superclassName)
112113
KEY(hasDefaultArg)
113114
KEY(conformingProtocols)
114115
KEY(enumRawTypeName)

test/api-digester/Inputs/cake1.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ public protocol RequiementChanges {
8989
associatedtype removedType
9090
var removedVar: Int {get}
9191
}
92+
93+
public class SuperClassRemoval: C3 {}

test/api-digester/Inputs/cake2.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ public protocol RequiementChanges {
9696
func addedFunc()
9797
var addedVar: Int { get }
9898
}
99+
100+
public class SuperClassRemoval {}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ cake1: AssociatedType AssociatedTypePro.T1 has removed default type Int
5959
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
6060
cake2: Func RequiementChanges.addedFunc() has been added as a protocol requirement
6161
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement
62+
63+
/* Class Inheritance Change */
64+
cake1: Class C4 has changed its super class from OldType to NewType
65+
cake1: Class SuperClassRemoval has removed its super class C3

test/api-digester/Outputs/Cake.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@ cake1: Struct fixedLayoutStruct has removed conformance to P1
4444
cake1: AssociatedType AssociatedTypePro.T1 has removed default type Int
4545
cake2: AssociatedType RequiementChanges.addedTypeWithoutDefault has been added as a protocol requirement
4646
cake2: Func RequiementChanges.addedFunc() has been added as a protocol requirement
47-
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement
47+
cake2: Var RequiementChanges.addedVar has been added as a protocol requirement
48+
49+
/* Class Inheritance Change */
50+
cake1: Class C4 has changed its super class from OldType to NewType
51+
cake1: Class SuperClassRemoval has removed its super class C3

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
"location": "",
199199
"moduleName": "cake",
200200
"superclassUsr": "s:4cake2C0C",
201+
"superclassName": "C0",
201202
"children": [
202203
{
203204
"kind": "Function",

test/api-digester/Outputs/cake.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
"location": "",
206206
"moduleName": "cake",
207207
"superclassUsr": "s:4cake2C0C",
208+
"superclassName": "C0",
208209
"children": [
209210
{
210211
"kind": "Function",

test/api-digester/Outputs/clang-module-dump.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"location": "",
1313
"moduleName": "Foo",
1414
"superclassUsr": "c:objc(cs)NSObject",
15+
"superclassName": "NSObject",
1516
"conformingProtocols": [
1617
"ObjcProt",
1718
"NSObjectProtocol"

0 commit comments

Comments
 (0)