> On Oct 24, 2016, at 2:24 PM, Ryan Lovelett via swift-users > <swift-users@swift.org> wrote: > > import CommonCrypto > > protocol Foo { > associatedtype Context > var context: Context { get set } > var bar: (UnsafeMutablePointer<Context>!, UnsafeRawPointer!, CC_LONG) > -> Int32 { get } > } > > struct SHA1: Foo { > var context: CC_SHA1_CTX > var bar: (UnsafeMutablePointer<CC_SHA1_CTX>!, UnsafeRawPointer!, > CC_LONG) -> Int32 = CC_SHA1_Update > } > > Unfortunately this will not compile any longer with Swift 3.0. The error > is: Implicitly unwrapped optionals are only allowed at top level and as > function results. > > I can try modifying `bar` definition to be `?` instead of `!` but then > `CC_SHA1_Update`) can no longer be assigned to `bar`. > > Suggestions?
Not being able to assign the function reference is a bug. As a workaround, you should be able to unsafeBitCast CC_SHA1_Update to the appropriate type. -Joe _______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users