<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 3, 2016, at 10:26 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="">Is another hack the way to go, or should it be correctly imported as [@convention(block) () -> ()] (which I think would be _isBridgedToObjectiveC already)?</div></div></blockquote><div><br class=""></div><div>Bridging to @convention(block) is probably more practical, since we'd otherwise need to be able to thunk an arbitrary call signature at runtime. However, @convention(block) is still a structural type, so it would need special case handling similar to _BridgeableMetatype to be able to feed a _BridgedToObjectiveC conformance into the runtime.</div><div><br class=""></div><div>-Joe</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra">
<br class=""><div class="gmail_quote">On Thu, Mar 3, 2016 at 9:08 AM, Joe Groff <span dir="ltr" class=""><<a href="mailto:jgroff@apple.com" target="_blank" class="">jgroff@apple.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class="h5"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 3, 2016, at 2:23 AM, Jacob Bandes-Storch via swift-dev <<a href="mailto:swift-dev@swift.org" target="_blank" class="">swift-dev@swift.org</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">I'm interested in fixing a pet peeve of mine: <a href="https://bugs.swift.org/browse/SR-772" target="_blank" class="">https://bugs.swift.org/browse/SR-772</a></div><div class=""><br class=""></div><div class="">The failing assertion is in Array._forceBridgeFromObjectiveC, namely <span class="">Swift._isBridgedToObjectiveC(Element.</span><span class="">self</span><span class="">). </span><span class="">Element is plain ol "() -> ()", but probably should be @convention(block) since it was imported from void(^)(void).</span></div><div class=""><br class=""></div><div class="">I've started tracing through the importer, and I found that `adjustTypeForConcreteImport` is enforcing FunctionTypeRepresentation::Swift because the ImportKind is BridgedValue — this is hardcoded in the call to importType for the type parameters to NSArray (and NSDictionary and NSSet) in SwiftTypeConverter::VisitObjCObjectPointerType.</div>
<div class=""><br class=""></div><div class="">Are the Foundation collection classes only temporarily special-cased here, until Obj-C generics are generally supported? Is someone working on this in the near future?</div><div class=""><br class=""></div><div class="">If this worked correctly, would we expect to see "var executionBlocks: [@convention(block) () -> ()]" ? If so, would this be best achieved by passing a different ImportKind, possibly introducing a new ImportKind, or some other solution?</div><div class=""><br class=""></div><div class="">I'm guessing that it doesn't make sense for () -> () to be _ObjectiveCBridgeable, but either way I'm not sure where the _isBridgedToObjectiveC implementation for blocks would come from.</div><br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div class="">Bumblingly,</div><div class="">Jacob<br class=""></div></div></div></div>
</div></div></blockquote><br class=""></div></div></div><div class="">There's a hack to handle NSArray<Class> * bridging to [AnyObject.Type], which has similar problems. Look around for _BridgeableMetatype.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-Joe</div><br class=""></font></span></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></body></html>