Skip to content

Commit 64ef8ec

Browse files
authored
Merge pull request #19590 from nkcsgexi/canonical-super-classtype
swift-module-digester: always canonicalize super class types.
2 parents 65b4f12 + 7b45ae9 commit 64ef8ec

16 files changed

+365
-198
lines changed

include/swift/AST/DiagnosticsModuleDiffer.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ ERROR(super_class_changed,none,"%0 has changed its super class from %1 to %2", (
7474

7575
ERROR(nominal_type_kind_changed,none,"%0 has been changed to a %1", (StringRef, StringRef))
7676

77+
ERROR(optional_req_changed,none,"%0 is %select{now|no longer}1 an optional requirement", (StringRef, bool))
78+
79+
ERROR(var_let_changed,none,"%0 changes from %select{var|let}1 to %select{let|var}1", (StringRef, bool))
80+
81+
ERROR(no_longer_open,none,"%0 is no longer open for subclassing", (StringRef))
82+
83+
ERROR(func_type_escaping_changed,none,"%0 has %select{removed|added}2 @escaping in %1", (StringRef, StringRef, bool))
84+
7785
#ifndef DIAG_NO_UNDEF
7886
# if defined(DIAG)
7987
# undef DIAG

include/swift/IDE/APIDigesterData.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class DiagnosticEngine;
2727
namespace ide {
2828
namespace api {
2929

30+
enum class KeyKind {
31+
#define KEY(NAME) KK_##NAME,
32+
#include "swift/IDE/DigesterEnums.def"
33+
};
34+
3035
// The node kind appearing in the tree that describes the content of the SDK
3136
enum class SDKNodeKind: uint8_t {
3237
#define NODE_KIND(NAME, VALUE) NAME,

include/swift/IDE/DigesterEnums.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ KEY_BOOL(IsOverriding, overriding)
124124
KEY_BOOL(IsProtocolReq, protocolReq)
125125
KEY_BOOL(HasDefaultArg, hasDefaultArg)
126126
KEY_BOOL(HasSetter, hasSetter)
127+
KEY_BOOL(IsLet, isLet)
128+
KEY_BOOL(IsOpen, isOpen)
127129

128130
KEY(kind)
129131

test/api-digester/Inputs/cake.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ extension S1: P2 {}
1515

1616
public class C0<T1, T2, T3> {}
1717

18-
public class C1: C0<S1, S1, S1> {
18+
public typealias C0Alias = C0<S1, S1, S1>
19+
20+
public class C1: C0Alias {
1921
open class func foo1() {}
2022
public weak var Ins : C1?
2123
public unowned var Ins2 : C1 = C1()
@@ -76,3 +78,5 @@ public protocol PSub: PSuper {
7678
associatedtype T
7779
func foo()
7880
}
81+
82+
public let GlobalVar = 1

test/api-digester/Inputs/cake1.swift

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,26 @@ public class SuperClassChange: C7 {}
102102

103103
public class GenericClass<T> {}
104104

105-
public class SubGenericClass: GenericClass<P1> {}
105+
public class SubGenericClass: GenericClass<P1> {}
106+
107+
@objc
108+
public protocol ObjCProtocol {
109+
@objc
110+
optional func removeOptional()
111+
@objc
112+
func addOptional()
113+
}
114+
115+
public let GlobalLetChangedToVar = 1
116+
public var GlobalVarChangedToLet = 1
117+
118+
public class ClassWithOpenMember {
119+
open class func foo() {}
120+
open var property: Int {get { return 1}}
121+
open func bar() {}
122+
}
123+
124+
public class EscapingFunctionType {
125+
public func removedEscaping(_ a: @escaping ()->()) {}
126+
public func addedEscaping(_ a: ()->()) {}
127+
}

test/api-digester/Inputs/cake2.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,25 @@ public class SuperClassChange: C8 {}
113113
public class GenericClass<T> {}
114114

115115
public class SubGenericClass: GenericClass<P2> {}
116+
117+
@objc
118+
public protocol ObjCProtocol {
119+
@objc
120+
func removeOptional()
121+
@objc
122+
optional func addOptional()
123+
}
124+
125+
public var GlobalLetChangedToVar = 1
126+
public let GlobalVarChangedToLet = 1
127+
128+
public class ClassWithOpenMember {
129+
public class func foo() {}
130+
public var property: Int {get { return 1}}
131+
public func bar() {}
132+
}
133+
134+
public class EscapingFunctionType {
135+
public func removedEscaping(_ a: ()->()) {}
136+
public func addedEscaping(_ a: @escaping ()->()) {}
137+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
1313
cake1: Func C4.foo() has been removed
1414
cake1: Func RequiementChanges.removedFunc() has been removed
1515
cake1: Subscript RemoveSetters.subscript(_:) has removed its setter
16+
cake1: Var GlobalVarChangedToLet has removed its setter
1617
cake1: Var RemoveSetters.Value has removed its setter
1718
cake1: Var RequiementChanges.removedVar has been removed
1819

@@ -30,6 +31,8 @@ cake1: Constructor S1.init(_:) has parameter 0 type change from Int to Double
3031
cake1: Func C1.foo2(_:) has parameter 0 type change from Int to () -> ()
3132
cake1: Func C7.foo(_:_:) has removed default argument from parameter 0
3233
cake1: Func C7.foo(_:_:) has removed default argument from parameter 1
34+
cake1: Func EscapingFunctionType.addedEscaping(_:) has added @escaping in parameter 0
35+
cake1: Func EscapingFunctionType.removedEscaping(_:) has removed @escaping in parameter 0
3336
cake1: Func Somestruct2.foo1(_:) has parameter 0 type change from C3 to C1
3437

3538
/* Decl Attribute changes */
@@ -42,6 +45,8 @@ cake1: Func S1.foo3() is now static
4245
cake1: Struct C6 is now with @_fixed_layout
4346
cake1: Var C1.CIIns1 changes from weak to strong
4447
cake1: Var C1.CIIns2 changes from strong to weak
48+
cake1: Var GlobalLetChangedToVar changes from let to var
49+
cake1: Var GlobalVarChangedToLet changes from var to let
4550

4651
/* Fixed-layout Type changes */
4752
cake1: EnumElement FrozenKind.Fixed in a non-resilient type changes position from 1 to 2
@@ -53,6 +58,8 @@ cake2: Var fixedLayoutStruct.c is added to a non-resilient type
5358
cake2: Var fixedLayoutStruct.lazy_d.storage is added to a non-resilient type
5459

5560
/* Conformance changes */
61+
cake1: Func ObjCProtocol.addOptional() is now an optional requirement
62+
cake1: Func ObjCProtocol.removeOptional() is no longer an optional requirement
5663
cake1: Protocol P3 has added inherited protocol P4
5764
cake1: Protocol P3 has removed inherited protocol P2
5865
cake1: Struct fixedLayoutStruct has removed conformance to P1

test/api-digester/Outputs/Cake.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ cake1: Constructor fixedLayoutStruct.init(b:a:) has been removed
1212
cake1: Func C4.foo() has been removed
1313
cake1: Func RequiementChanges.removedFunc() has been removed
1414
cake1: Subscript RemoveSetters.subscript(_:) has removed its setter
15+
cake1: Var GlobalVarChangedToLet has removed its setter
1516
cake1: Var RemoveSetters.Value has removed its setter
1617
cake1: Var RequiementChanges.removedVar has been removed
1718

@@ -38,6 +39,7 @@ cake1: Var C1.CIIns1 changes from weak to strong
3839
cake1: Var C1.CIIns2 changes from strong to weak
3940

4041
/* Conformance changes */
42+
cake1: Func ObjCProtocol.removeOptional() is no longer an optional requirement
4143
cake1: Protocol P3 has added inherited protocol P4
4244
cake1: Protocol P3 has removed inherited protocol P2
4345
cake1: Struct fixedLayoutStruct has removed conformance to P1
@@ -52,3 +54,6 @@ cake2: Var RequiementChanges.addedVar has been added as a protocol requirement
5254
cake1: Class C4 has changed its super class from OldType to NewType
5355
cake1: Class SubGenericClass has changed its super class from GenericClass<P1> to GenericClass<P2>
5456
cake1: Class SuperClassRemoval has removed its super class C3
57+
cake1: Func ClassWithOpenMember.bar() is no longer open for subclassing
58+
cake1: Func ClassWithOpenMember.foo() is no longer open for subclassing
59+
cake1: Var ClassWithOpenMember.property is no longer open for subclassing

0 commit comments

Comments
 (0)