File tree Expand file tree Collapse file tree 4 files changed +50
-13
lines changed
validation-test/Evolution Expand file tree Collapse file tree 4 files changed +50
-13
lines changed Original file line number Diff line number Diff line change @@ -64,22 +64,22 @@ open class OpenClass {
64
64
}
65
65
66
66
// Inserting a superclass
67
- open class Bottom {
67
+ open class Top {
68
68
public init ( ) { }
69
69
70
- open func bottomMethod ( ) { }
70
+ open func topMethod ( ) { }
71
71
}
72
72
73
73
#if BEFORE
74
74
75
- open class Top : Bottom { }
75
+ open class Bottom : Top { }
76
76
77
77
#else
78
78
79
- @_weakLinked open class Middle : Bottom {
79
+ @_weakLinked open class Middle : Top {
80
80
open func middleMethod( ) { }
81
81
}
82
82
83
- open class Top : Middle { }
83
+ open class Bottom : Middle { }
84
84
85
85
#endif
Original file line number Diff line number Diff line change @@ -9,13 +9,17 @@ public func getVersion() -> Int {
9
9
public protocol OtherProtocol {
10
10
init ( )
11
11
}
12
- public struct OtherConcrete : OtherProtocol {
12
+
13
+ #if AFTER
14
+ // Protocol is always available, type is weak-linked
15
+ @_weakLinked public struct OtherConforms : OtherProtocol {
13
16
public init ( ) { }
14
17
}
18
+ #endif
15
19
16
20
public protocol OldProtocol {
17
21
#if AFTER
18
- @_weakLinked associatedtype NewType : OtherProtocol = OtherConcrete
22
+ @_weakLinked associatedtype NewType : OtherProtocol = OtherConforms
19
23
@_weakLinked func newMethod( ) -> NewType
20
24
#endif
21
25
}
@@ -28,6 +32,7 @@ extension OldProtocol {
28
32
}
29
33
#endif
30
34
35
+ // Protocol is weak-linked, type is always available
31
36
#if AFTER
32
37
@_weakLinked public protocol NewProtocol {
33
38
func newMethod( )
@@ -44,3 +49,12 @@ public struct NewConforms {
44
49
}
45
50
#endif
46
51
52
+ // Protocol and type are always available, conformace is weak-linked
53
+ public struct NewConformanceConforms {
54
+ public init ( ) { }
55
+ }
56
+ public protocol NewConformanceProtocol { }
57
+
58
+ #if AFTER
59
+ @_weakLinked extension NewConformanceConforms : NewConformanceProtocol { }
60
+ #endif
Original file line number Diff line number Diff line change @@ -70,12 +70,12 @@ BackwardDeployClassTest.test("OpenClass") {
70
70
}
71
71
72
72
BackwardDeployClassTest . test ( " InsertSuperclass " ) {
73
- class DerivedClass : Top {
73
+ class DerivedClass : Bottom {
74
74
var count : Int = 0
75
75
76
- override func bottomMethod ( ) {
76
+ override func topMethod ( ) {
77
77
count += 1
78
- super. bottomMethod ( )
78
+ super. topMethod ( )
79
79
}
80
80
81
81
override func middleMethod( ) {
@@ -86,7 +86,7 @@ BackwardDeployClassTest.test("InsertSuperclass") {
86
86
87
87
let d = DerivedClass ( )
88
88
89
- d. bottomMethod ( )
89
+ d. topMethod ( )
90
90
if getVersion ( ) == 1 {
91
91
d. middleMethod ( )
92
92
expectEqual ( d. count, 11 )
Original file line number Diff line number Diff line change @@ -16,8 +16,14 @@ struct ConformsToOldWithNonDefault : OldProtocol {
16
16
17
17
BackwardDeployProtocolTest . test ( " OldProtocol " ) {
18
18
if getVersion ( ) == 1 {
19
- _ = ConformsToOldWithDefault ( ) . newMethod ( )
20
- _ = ConformsToOldWithNonDefault ( ) . newMethod ( )
19
+ // FIXME: IRGen inserts the metadata load outside the version check
20
+ // apparently. Work around that here. <rdar://problem/46438608>
21
+ @inline ( never) func helper( ) {
22
+ _ = ConformsToOldWithDefault ( ) . newMethod ( )
23
+ _ = ConformsToOldWithNonDefault ( ) . newMethod ( )
24
+ }
25
+
26
+ helper ( )
21
27
}
22
28
}
23
29
@@ -67,6 +73,23 @@ BackwardDeployProtocolTest.test("RefinedProtocol") {
67
73
}
68
74
}
69
75
76
+ // Witness tables that are weak-linked for various reasons
77
+ BackwardDeployProtocolTest . test ( " WeakWitnessTables " ) {
78
+ if getVersion ( ) == 1 {
79
+ // FIXME: IRGen inserts the metadata load outside the version check
80
+ // apparently. Work around that here. <rdar://problem/46438608>
81
+ @inline ( never) func helper( ) {
82
+ func f1< T : OtherProtocol > ( _: T ) { }
83
+ func f2< T : NewProtocol > ( _: T ) { }
84
+ func f3< T : NewConformanceProtocol > ( _: T ) { }
85
+
86
+ f1 ( OtherConforms ( ) )
87
+ f2 ( NewConforms ( ) )
88
+ f3 ( NewConformanceConforms ( ) )
89
+ }
90
+ }
91
+ }
92
+
70
93
// Conditional conformance with weak-linked requirement
71
94
struct Box < T> { }
72
95
You can’t perform that action at this time.
0 commit comments