// RUN: %target-swift-frontend -disable-type-layout -emit-ir -module-name outcopyaddr -primary-file %s | %FileCheck %s public protocol BaseProt { } public protocol ChildProt: BaseProt { } public struct BaseStruct { public typealias Element = T public var elem1: Element public var elem2: Element } public struct StructWithBaseStruct { public typealias Element = T var elem1: Element var elem2: BaseStruct } // CHECK-LABEL: define hidden swiftcc void @"$s11outcopyaddr010StructWithbc4BaseB0V4elemAA0bcdB0VyxGvg"(ptr noalias sret({{.*}}) %0, ptr %"StructWithStructWithBaseStruct", ptr noalias swiftself %1) // CHECK: call ptr @"$s11outcopyaddr014StructWithBaseB0VyxGAA9ChildProtRzlWOc" public struct StructWithStructWithBaseStruct { public typealias Element = T let elem: StructWithBaseStruct } protocol P { } class OtherPrivate { } struct OtherInternal { var myPrivate: OtherPrivate? = nil } struct MyPrivate { var otherHelper: OtherInternal? = nil // CHECK-LABEL: define hidden swiftcc {{i32|i64}} @"$s11outcopyaddr9MyPrivateVyACyxGxcfC"(ptr noalias %0, ptr %T, ptr %T.P) {{.*}} { // CHECK: call ptr @"$s11outcopyaddr9MyPrivateVyxGAA1PRzlWOh"(ptr {{%.*}}) // CHECK: ret init(_: T) { } } extension P { func foo(data: Any) { _ = MyPrivate(data as! Self) } } enum GenericError { case payload(T) } func testIt(_ f: GenericError

?) { } func dontCrash(_ f: GenericError

) { testIt(f) } protocol Baz : class { } extension Baz { static func crash(setup: ((Self) -> ())?){ } } class Foobar { public static func dontCrash() -> Baz? { let cls : Baz.Type = Foobar1.self // This used to crash because we tried to outline the optional consume with // an opened payload existential type. cls.crash(setup: { (arg: Baz) -> () in }) return nil } } class Foobar1 : Foobar, Baz { }