// RUN: %target-swift-frontend -sdk %S/Inputs %s -emit-silgen | %FileCheck %s // REQUIRES: objc_interop import ansible var a = NSAnse(Ansible(bellsOn: NSObject())) var anse = NSAnse hasNoPrototype() // CHECK-LABEL: sil @main // -- Foreign function is referenced with C calling conv and ownership semantics // CHECK: [[NSANSE:%.*]] = function_ref @NSAnse : $@convention(c) (Optional) -> @autoreleased Optional // CHECK: [[ANSIBLE_CTOR:%.*]] = function_ref @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC // CHECK: [[NSOBJECT_CTOR:%.*]] = function_ref @_T0So8NSObjectC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick NSObject.Type) -> @owned NSObject // CHECK: [[ANSIBLE:%.*]] = apply [[ANSIBLE_CTOR]] // CHECK: [[NSANSE_RESULT:%.*]] = apply [[NSANSE]]([[ANSIBLE]]) // CHECK: destroy_value [[ANSIBLE]] : $Optional // -- Referencing unapplied C function goes through a thunk // CHECK: [[NSANSE:%.*]] = function_ref @_T0So6NSAnseSQySo7AnsibleCGADFTO : $@convention(thin) (@owned Optional) -> @owned Optional // -- Referencing unprototyped C function passes no parameters // CHECK: [[NOPROTO:%.*]] = function_ref @hasNoPrototype : $@convention(c) () -> () // CHECK: apply [[NOPROTO]]() // -- Constructors for imported Ansible // CHECK-LABEL: sil shared [serializable] @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@in Optional, @thick Ansible.Type) -> @owned Optional // -- Constructors for imported NSObject // CHECK-LABEL: sil shared [serializable] @_T0So8NSObjectC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick NSObject.Type) -> @owned NSObject // -- Native Swift thunk for NSAnse // CHECK: sil shared [serialized] [thunk] @_T0So6NSAnseSQySo7AnsibleCGADFTO : $@convention(thin) (@owned Optional) -> @owned Optional { // CHECK: bb0(%0 : $Optional): // CHECK: %1 = function_ref @NSAnse : $@convention(c) (Optional) -> @autoreleased Optional // CHECK: %2 = apply %1(%0) : $@convention(c) (Optional) -> @autoreleased Optional // CHECK: destroy_value %0 : $Optional // CHECK: return %2 : $Optional // CHECK: } // -- Constructor for imported Ansible was unused, should not be emitted. // CHECK-NOT: sil {{.*}} @_T0So7AnsibleC{{[_0-9a-zA-Z]*}}fC : $@convention(method) (@thick Ansible.Type) -> @owned Ansible