import StdlibUnittest // rdar://125886333 public struct GenericExternalKeyPathTest { public private(set) var property: String { get { return "\(E.self)" } set { } } public init() {} } public struct A { public var x: Int { return 0 } // NB: These declarations intentionally do not constrain the index type // to be Hashable, to ensure that we get the Hashable conformance from // the context where the key path was formed for equality while using the // property descriptor's accessors. public subscript(withGeneric index: T) -> T { return index } public private(set) subscript(withGenericPrivateSet index: T) -> T { get { return index } set { } } public subscript(withGenericSettable index: T) -> T { get { return index } set { } } public var storedA: B public private(set) var storedB: Double public var y: Int { get { return 0 } set { } } public private(set) var z: Int { get { return 0 } set { } } public internal(set) var w: Int { get { return 0 } set { } } public fileprivate(set) var v: Int { get { return 0 } set { } } public let immutable: Int = 1738 } public struct B { public var x: Int { return 0 } public var y: Int { get { return 0 } set { } } public private(set) var z: Int { get { return 0 } set { } } public subscript(withInt i: Int) -> Int { return i } // NB: These declarations intentionally do not constrain the index type // to be Hashable, to ensure that we get the Hashable conformance from // the context where the key path was formed for equality while using the // property descriptor's accessors. public subscript(withGeneric i: T) -> T { return i } public private(set) subscript(withGenericPrivateSet index: T) -> T { get { return index } set { } } public subscript(withGenericSettable index: T) -> T { get { return index } set { } } public var storedA: U public internal(set) var storedB: U } public func A_x_keypath() -> KeyPath { return \A.x } public func A_y_keypath() -> KeyPath { return \A.y } public func A_z_keypath() -> KeyPath { return \A.z } public func A_w_keypath() -> KeyPath { return \A.w } public func A_v_keypath() -> KeyPath { return \A.v } public func A_immutable_keypath() -> KeyPath { return \A.immutable } public func A_subscript_withGeneric_keypath(index: T) -> KeyPath { return \A.[withGeneric: index] } public func A_subscript_withGenericSettable_keypath(index: T) -> KeyPath { return \A.[withGenericSettable: index] } public func A_subscript_withGenericPrivateSet_keypath(index: T) -> KeyPath { return \A.[withGenericPrivateSet: index] } public func A_subscript_withGeneric_butt_keypath() -> KeyPath { return \A.[withGeneric: "pomeranian's big butt"] } public func B_subscript_withInt_keypath(_: T.Type, index: Int) -> KeyPath, Int> { return \B.[withInt: index] } public func B_Double_subscript_withInt_0_keypath() -> KeyPath, Int> { return \B.[withInt: 0] } public func B_subscript_withGeneric_keypath( _: T.Type, index: U ) -> KeyPath, U> { return \B.[withGeneric: index] } public func B_subscript_withGenericSettable_keypath( _: T.Type, index: U ) -> KeyPath, U> { return \B.[withGenericSettable: index] } public func B_subscript_withGenericPrivateSet_keypath( _: T.Type, index: U ) -> KeyPath, U> { return \B.[withGenericPrivateSet: index] } public func B_Double_subscript_withGeneric_butt_keypath() -> KeyPath, String> { return \B.[withGeneric: "Never is the universal butt type"] } public func A_storedA_keypath() -> KeyPath> { return \A.storedA } public func A_storedA_storedB_keypath() -> KeyPath { return \A.storedA.storedB } public func A_storedB_keypath() -> KeyPath { return \A.storedB } public func B_x_keypath(_: T.Type) -> KeyPath, Int> { return \B.x } public func B_y_keypath(_: T.Type) -> KeyPath, Int> { return \B.y } public func B_z_keypath(_: T.Type) -> KeyPath, Int> { return \B.z } public func B_Int_x_keypath() -> KeyPath, Int> { return \B.x } public func B_Int_y_keypath() -> KeyPath, Int> { return \B.y } public func B_Int_z_keypath() -> KeyPath, Int> { return \B.z } public func B_storedA_keypath(_: T.Type) -> KeyPath, T> { return \B.storedA } public func B_storedB_keypath(_: T.Type) -> KeyPath, T> { return \B.storedB } public func B_Int_storedA_keypath() -> KeyPath, Int> { return \B.storedA } public func B_Int_storedB_keypath() -> KeyPath, Int> { return \B.storedB } open class ResilientRoot { open var storedA = "a" open var storedB = "b" public let storedLet = "c" open var virtual: String { get { return "foo" } set { } } open var virtualRO: String { get { return "foo" } } final public var final: String { get { return "foo" } set { } } } open class ResilientSub: ResilientRoot { open var storedC = "c" override open var virtual: String { get { return "bar" } set { } } open var sub: String { get { return "bar" } set { } } open var subRO: String { get { return "foo" } } } public func ResilientRoot_storedA_keypath() -> KeyPath { return \ResilientRoot.storedA } public func ResilientRoot_storedB_keypath() -> KeyPath { return \ResilientRoot.storedB } public func ResilientRoot_storedLet_keypath() -> KeyPath { return \ResilientRoot.storedLet } public func ResilientRoot_virtual_keypath() -> KeyPath { return \ResilientRoot.virtual } public func ResilientRoot_virtualRO_keypath() -> KeyPath { return \ResilientRoot.virtualRO } public func ResilientRoot_final_keypath() -> KeyPath { return \ResilientRoot.final } public func ResilientSub_storedA_keypath() -> KeyPath { return \ResilientSub.storedA } public func ResilientSub_storedB_keypath() -> KeyPath { return \ResilientSub.storedB } public func ResilientSub_storedC_keypath() -> KeyPath { return \ResilientSub.storedC } public func ResilientSub_virtual_keypath() -> KeyPath { return \ResilientSub.virtual } public func ResilientSub_virtualRO_keypath() -> KeyPath { return \ResilientSub.virtualRO } public func ResilientSub_final_keypath() -> KeyPath { return \ResilientSub.final } public func ResilientSub_sub_keypath() -> KeyPath { return \ResilientSub.sub } public func ResilientSub_subRO_keypath() -> KeyPath { return \ResilientSub.subRO } public protocol ResilientRootProto { var root: String { get } } public protocol ResilientSubProto: ResilientRootProto { var sub: String { get } } extension Int: ResilientSubProto { public var root: String { return "root" } public var sub: String { return "sub" } } public func ResilientRootProto_root_keypath(_: T.Type) -> KeyPath { return \T.root } public func ResilientSubProto_sub_keypath(_: T.Type) -> KeyPath { return \T.sub } extension Int { public var appendTest: Int { return self } } extension String { public var appendTest: String { return self } } extension LifetimeTracked { public var appendTest: LifetimeTracked { return self } }