7
7
8
8
class MyLabel {
9
9
var text = " label "
10
+ static var isVisible = true
10
11
}
11
12
12
13
class Controller {
13
14
14
15
fileprivate let label = MyLabel ( )
15
16
fileprivate var secondLabel : MyLabel ? = MyLabel ( )
16
17
public var thirdLabel : MyLabel ? = MyLabel ( )
18
+ fileprivate var fourthLabel : MyLabel . Type ? { return MyLabel . self }
19
+ public var fifthLabel : MyLabel . Type ? { return MyLabel . self }
17
20
18
21
subscript( string: String ) -> String {
19
22
get {
@@ -56,6 +59,7 @@ class Controller {
56
59
57
60
struct S {
58
61
var a : Int
62
+ static let b : Double = 100.0
59
63
}
60
64
61
65
struct Container < V> {
@@ -77,6 +81,22 @@ extension Container where V: Controller {
77
81
// CHECK: label
78
82
print ( Container ( Controller ( ) ) . test ( ) )
79
83
84
+ struct MetatypeContainer < V> {
85
+ var v : V . Type
86
+ init ( _ v: V . Type ) {
87
+ self . v = v
88
+ }
89
+ func useMetatypeKeyPath( ) -> Bool {
90
+ if let labelType = v as? MyLabel . Type {
91
+ return labelType. isVisible
92
+ }
93
+ return false
94
+ }
95
+ }
96
+
97
+ // CHECK: true
98
+ print ( MetatypeContainer ( MyLabel . self) . useMetatypeKeyPath ( ) )
99
+
80
100
public class GenericController < U> {
81
101
init ( _ u: U ) {
82
102
self . u = u
@@ -123,6 +143,15 @@ print(\Controller[array: [42]])
123
143
// CHECK: \Controller.
124
144
print ( \Controller [ array: [ 42 ] , array2: [ 42 ] ] )
125
145
146
+ // CHECK: \Controller.fourthLabel!.<computed {{.*}} (Bool)>
147
+ print ( \Controller . fourthLabel!. isVisible)
148
+
149
+ // CHECK: \S.Type.<computed {{.*}} (Double)>
150
+ print ( \S . Type. b)
151
+ // CHECK: \Controller.fifthLabel?.<computed {{.*}} (Bool)>?
152
+ print ( \Controller . fifthLabel? . isVisible)
153
+
154
+
126
155
do {
127
156
struct S {
128
157
var i : Int
@@ -162,3 +191,18 @@ do {
162
191
// CHECK: {{\\S2\.subscript\(_: S1 #[0-9]+\)|\S2\.<computed 0x.* \(String\)>}}
163
192
print ( kp)
164
193
}
194
+
195
+ do {
196
+ struct Weekday {
197
+ static let day = " Monday "
198
+ }
199
+
200
+ @dynamicMemberLookup
201
+ struct StaticExample < T> {
202
+ subscript< U> ( dynamicMember keyPath: KeyPath < T . Type , U > ) -> U {
203
+ return T . self [ keyPath: keyPath]
204
+ }
205
+ }
206
+ // CHECK: true
207
+ print ( StaticExample < MyLabel > ( ) . isVisible)
208
+ }
0 commit comments