File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -193,9 +193,14 @@ ErrorTests.test("test dealloc empty error box") {
193
193
194
194
var errors : [ Error ] = [ ]
195
195
ErrorTests . test ( " willThrow " ) {
196
- typealias WillThrow = @convention ( c) ( Error ) -> Void
196
+ // Error isn't allowed in a @convention(c) function when ObjC interop is
197
+ // not available, so pass it through an OpaquePointer.
198
+ typealias WillThrow = @convention ( c) ( OpaquePointer ) -> Void
197
199
let willThrow = pointerToSwiftCoreSymbol ( name: " _swift_willThrow " ) !
198
- willThrow. storeBytes ( of: { errors. append ( $0) } , as: WillThrow . self)
200
+ let callback : WillThrow = {
201
+ errors. append ( unsafeBitCast ( $0, to: Error . self) )
202
+ }
203
+ willThrow. storeBytes ( of: callback, as: WillThrow . self)
199
204
expectTrue ( errors. isEmpty)
200
205
do {
201
206
throw UnsignedError . negativeOne
You can’t perform that action at this time.
0 commit comments