Skip to content

Commit

Permalink
Merge pull request #537 from Quick/noescape-workaround
Browse files Browse the repository at this point in the history
🐛Workaround to noescape bug in Xcode 10 beta 1
  • Loading branch information
ikesyo committed Jun 14, 2018
2 parents 93d4a94 + ec4db80 commit 69bb161
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Sources/Nimble/Adapters/AssertionRecorder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ public func withAssertionHandler(_ tempAssertionHandler: AssertionHandler, closu
environment.assertionHandler = oldRecorder
}))
environment.assertionHandler = tempAssertionHandler
capturer.tryBlock {
try! closure()
// TEMP: withoutActuallyEscaping is workaround to Radar 40857699
// https://openradar.appspot.com/radar?id=5595735974215680
withoutActuallyEscaping(closure) { escapable in
capturer.tryBlock {
try! escapable()
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion Sources/NimbleObjectiveC/NMBExceptionCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
@interface NMBExceptionCapture : NSObject

- (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnull))handler finally:(void(^ _Nullable)(void))finally;
- (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock NS_SWIFT_NAME(tryBlock(_:));

/**
TEMP: unsafeBlock should be annotated with __attribute__((noescape)). This was removed
as a workaround to Radar 40857699 https://openradar.appspot.com/radar?id=5595735974215680
@param unsafeBlock Closure to run inside an @try block.
*/
- (void)tryBlock:(void(^ _Nonnull)(void))unsafeBlock NS_SWIFT_NAME(tryBlock(_:));

@end

Expand Down
2 changes: 1 addition & 1 deletion Sources/NimbleObjectiveC/NMBExceptionCapture.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ - (nonnull instancetype)initWithHandler:(void(^ _Nullable)(NSException * _Nonnul
return self;
}

- (void)tryBlock:(__attribute__((noescape)) void(^ _Nonnull)(void))unsafeBlock {
- (void)tryBlock:(void(^ _Nonnull)(void))unsafeBlock {
@try {
unsafeBlock();
}
Expand Down

0 comments on commit 69bb161

Please sign in to comment.