Skip to content

Commit

Permalink
Prevent compiler inferring incorrect type
Browse files Browse the repository at this point in the history
Summary:
Fixes the build warning:

```react-native/React/Modules/RCTRedBox.m:406:58: Conversion from value of type 'NSArray<RCTJSStackFrame *> *' to incompatible type 'NSArray<NSDictionary *> *```

This appears because the compiler is left to infer the type of `stack`, and it does so as `NSArray<RCTJSStackFrame *>` based on [RCTRedBox.m#L390](https://github.com/facebook/react-native/blob/master/React/Modules/RCTRedBox.m#L390). In reality `stack` may be either of two types and the function body deals with normalisation.

Mark the stack as explicitly `NSArray<id>` to prevent inference so we're free to make the decision to cast to more specific types.
Closes #11807

Differential Revision: D4402916

fbshipit-source-id: 356343f244af7638b9b9e91c2c5b7e68de0cbd33
  • Loading branch information
robhogan authored and facebook-github-bot committed Jan 11, 2017
1 parent b27c541 commit 40f2b1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion React/Modules/RCTRedBox.m
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ - (void)updateErrorMessage:(NSString *)message withStack:(NSArray *)stack
[self showErrorMessage:message withStack:stack isUpdate:YES];
}

- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack isUpdate:(BOOL)isUpdate
- (void)showErrorMessage:(NSString *)message withStack:(NSArray<id> *)stack isUpdate:(BOOL)isUpdate
{
if (![[stack firstObject] isKindOfClass:[RCTJSStackFrame class]]) {
stack = [RCTJSStackFrame stackFramesWithDictionaries:stack];
Expand Down

0 comments on commit 40f2b1b

Please sign in to comment.