Deal with anonymous objc blocks where non closure args could wrongly be considered duplicates.

Reviewed By: dulmarod

Differential Revision: D8723502

fbshipit-source-id: d8b7fe8
master
Martin Trojer 6 years ago committed by Facebook Github Bot
parent 510ce07698
commit 63b3f5b99b

@ -38,7 +38,7 @@ let get_extended_args_for_method_with_block_analysis act_params =
in
append_no_duplicates_vars all_args captured
| _ ->
append_no_duplicates_vars all_args [act_param] )
List.append all_args [act_param] )
in
List.map ~f:(fun (exp, _, typ) -> (exp, typ)) args_and_captured

@ -74,6 +74,7 @@ SOURCES_BUCKET_ALL = \
returnstmt/return_npe_test.m \
shared/assertions/NSAssert_example.m \
shared/block/BlockVar.m \
shared/block/AnonymousBlock.m \
shared/block/block.m \
shared/block/block_no_args.m \
shared/block/block_release.m \

@ -0,0 +1,34 @@
/*
* Copyright (c) 2018-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
void anonBlock() {
CFRunLoopObserverRef observer = CFRunLoopObserverCreateWithHandler(
NULL,
kCFRunLoopBeforeWaiting,
NO,
UINT_MAX,
^(CFRunLoopObserverRef obs, CFRunLoopActivity activity) {
CFRelease(obs);
});
CFRunLoopAddObserver(CFRunLoopGetMain(), observer, kCFRunLoopCommonModes);
}
void blockVar() {
// This case doesnt fail like the one above (with the anonymous block) used
// to. That's because using the block variable populates the args list
// differently thus avoiding the dupliate.
void (^bvar)(CFRunLoopObserverRef observer, CFRunLoopActivity activity) =
^(CFRunLoopObserverRef obs, CFRunLoopActivity activity) {
CFRelease(obs);
};
CFRunLoopObserverRef observer = CFRunLoopObserverCreateWithHandler(
NULL, kCFRunLoopBeforeWaiting, NO, UINT_MAX, bvar);
CFRunLoopAddObserver(CFRunLoopGetMain(), observer, kCFRunLoopCommonModes);
}
Loading…
Cancel
Save