You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.2 KiB
63 lines
1.2 KiB
7 years ago
|
/*
|
||
6 years ago
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||
7 years ago
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
7 years ago
|
#import <Foundation/Foundation.h>
|
||
7 years ago
|
|
||
|
@interface DynamicDispatchClass : NSObject
|
||
|
@end
|
||
|
|
||
|
@implementation DynamicDispatchClass {
|
||
|
@public
|
||
|
int x;
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
@protocol P
|
||
|
|
||
|
- (DynamicDispatchClass*)get_ddclass;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@interface PInstance : NSObject<P>
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation PInstance
|
||
|
|
||
|
- (DynamicDispatchClass*)get_ddclass {
|
||
|
return nil;
|
||
|
}
|
||
|
|
||
|
@end
|
||
|
|
||
|
@interface DynamicDispatchMain : NSObject
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation DynamicDispatchMain
|
||
|
|
||
|
- (DynamicDispatchClass*)get_ddclass_from:(id<P>)object {
|
||
|
return [object get_ddclass];
|
||
|
}
|
||
|
|
||
|
- (int)npe_bad {
|
||
|
PInstance* object = [PInstance new];
|
||
|
return [self get_ddclass_from:object] -> x;
|
||
|
}
|
||
|
|
||
7 years ago
|
+ (int)dispatch_async_block_npe_bad {
|
||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
||
|
^{
|
||
|
PInstance* object = [PInstance new];
|
||
|
DynamicDispatchMain* main = [DynamicDispatchMain new];
|
||
|
int x = [main get_ddclass_from:object] -> x;
|
||
|
});
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
7 years ago
|
@end
|