// RUN: %target-run-simple-swift | %FileCheck %s // REQUIRES: executable_test class MyLabel { var text = "label" } class Controller { fileprivate let label = MyLabel() } struct Container { var v : V init(_ v: V) { self.v = v } func useKeyPath(_ keyPath: KeyPath) -> String { return (v[keyPath: keyPath] as! MyLabel).text } } extension Container where V: Controller { func test() -> String { return useKeyPath(\.label) } } // CHECK: label print(Container(Controller()).test()) public class GenericController { init(_ u: U) { self.u = u } var u : U fileprivate let label = MyLabel() } public func generic_class_constrainted_keypath(_ c: V) where V : GenericController { let kp = \V.label print(kp) print(c[keyPath: kp].text) } // CHECK: Swift.KeyPath, main.MyLabel> // CHECK: label generic_class_constrainted_keypath(GenericController(5))