<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 5, 2016, at 1:54 AM, Jacob Bandes-Storch <<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">I'm wading through little by little, but I clearly still have a lot to learn... sorry if I'm bothering you with questions!<div class=""><br class=""></div><div class="">Comparing the SIL for the `<b class="">completionBlock</b>` getter, which is imported as ()->()...<div class=""><br class=""></div><div class=""><div class=""> %15 = class_method [volatile] %14 : $NSOperation, #NSOperation.completionBlock!getter.1.foreign : NSOperation -> () -> <b class=""><i class="">(() -> ())?</i></b> , $@convention(objc_method) (NSOperation) -> @autoreleased <b class=""><i class="">Optional<@convention(block) () -> ()></i></b></div></div><div class=""><br class=""></div><div class=""> Here I see that "@convention(block)" is retained in the type information, and appears in the expanded form Optional<@convention(block) ()->()>, even though the getter completionBlock getter is of type "NSOperation -> () -> (() -> ())?", and ()->() is what we see in generated interfaces.</div><div class=""><br class=""></div><div class="">...vs. the `<b class="">executionBlocks</b>` getter, which is imported as [()->()]...<br class=""></div><div class=""><br class=""></div><div class=""><div class=""> %11 = class_method [volatile] %10 : $NSBlockOperation, #NSBlockOperation.executionBlocks!getter.1.foreign : NSBlockOperation -> () -> <b class=""><i class="">[() -> ()]</i></b> , $@convention(objc_method) (NSBlockOperation) -> @autoreleased Optional<NSArray></div><div class=""> %12 = apply %11(%10) : $@convention(objc_method) (NSBlockOperation) -> @autoreleased Optional<NSArray></div></div><div class=""><div class=""> %13 = function_ref @_TF10Foundation22_convertNSArrayToArrayurFGSqCSo7NSArray_GSax_ : $@convention(thin) <τ_0_0> (@owned Optional<NSArray>) -> @owned Array<τ_0_0></div><div class=""> %14 = apply <b class=""><i class="">%13<() -> ()></i></b>(%12) : $@convention(thin) <τ_0_0> (@owned Optional<NSArray>) -> @owned Array<τ_0_0></div></div></div><div class=""><div class=""> release_value %14 : <b class=""><i class="">$Array<() -> ()></i></b></div></div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">I don't see @convention(block) anywhere here. And when I check the type of static_cast<FunctionTypeMetadata*>(T)->getConvention(), from inside findBridgeWitness, the convention is Swift.</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">So not only is there no conformance for blocks (which seems like an easy thing to add, like you said, similarly to _BridgeableMetatype), but I think the @convention(block) is being <b class="">completely lost</b> by adjustTypeForConcreteImport. Is this true or am I missing something?</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">How is @convention(block) retained after importing in order to produce the right type from completionBlock.getter, namely Optional<@convention(block) ()->()>, but it appears only as Optional<()->()> in the generated interface? Why does this mechanism not produce a call to _convertNSArrayToArray<@convention(block) ()->()>, but only _convertNSArrayToArray<()->()> ?</div>
</div></div></blockquote><br class=""></div><div>I think this is a problem at the Clang importer level. It's probably assuming that if you have a parameter of type NSArray<T> in Objective-C, and T is bridgeable to BT, then it should always be imported as Array<BT> (and SILGen would be able to insert the conversions during code generation). If you want to preserve the block-ness, it may need a special case at that level.</div><br class=""></body></html>