77
88class MyLabel {
99 var text = " label "
10+ static var isVisible = true
1011}
1112
1213class Controller {
1314
1415 fileprivate let label = MyLabel ( )
1516 fileprivate var secondLabel : MyLabel ? = MyLabel ( )
1617 public var thirdLabel : MyLabel ? = MyLabel ( )
18+ fileprivate var fourthLabel : MyLabel . Type ? { return MyLabel . self }
19+ public var fifthLabel : MyLabel . Type ? { return MyLabel . self }
1720
1821 subscript( string: String ) -> String {
1922 get {
@@ -56,6 +59,7 @@ class Controller {
5659
5760struct S {
5861 var a : Int
62+ static let b : Double = 100.0
5963}
6064
6165struct Container < V> {
@@ -77,6 +81,22 @@ extension Container where V: Controller {
7781// CHECK: label
7882print ( Container ( Controller ( ) ) . test ( ) )
7983
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+
80100public class GenericController < U> {
81101 init ( _ u: U ) {
82102 self . u = u
@@ -123,6 +143,15 @@ print(\Controller[array: [42]])
123143// CHECK: \Controller.
124144print ( \Controller [ array: [ 42 ] , array2: [ 42 ] ] )
125145
146+ // CHECK: {{\\Controller\.(fourthLabel|<computed .* \(Optional<MyLabel\.Type>\)>)!\.<computed .* \(Bool\)>}}
147+ print ( \Controller . fourthLabel!. isVisible)
148+
149+ // CHECK: \S.Type.<computed {{.*}} (Double)>
150+ print ( \S . Type. b)
151+ // CHECK: {{\\Controller\.(fifthLabel|<computed .* \(Optional<MyLabel\.Type>\)>)\?\.<computed .* \(Bool\)>?}}
152+ print ( \Controller . fifthLabel? . isVisible)
153+
154+
126155do {
127156 struct S {
128157 var i : Int
@@ -162,3 +191,18 @@ do {
162191 // CHECK: {{\\S2\.subscript\(_: S1 #[0-9]+\)|\S2\.<computed 0x.* \(String\)>}}
163192 print ( kp)
164193}
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