Use correct var name for element when handling arrays of type aliases

Summary:
Fixes an issue where, if a spec uses an array of elements where the element is a type alias, the generated code would use the wrong variable name.

An example of such a spec can be found in `NativeExceptionsManager.js`:
```
  +reportSoftException: (
    message: string,
    stack: Array<StackFrame>,
    exceptionId: number,
  ) => void;
```

The fix ensures the local variable name is passed through, ensuring that either p or itemValue_N is used when appropriate.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D24116429

fbshipit-source-id: f39b75adb604c751d70a284a11a7fa6649b1344d
This commit is contained in:
Héctor Ramos
2020-10-05 12:57:34 -07:00
committed by Facebook GitHub Bot
parent 43624dd193
commit d4937b925b
2 changed files with 4 additions and 4 deletions
@@ -195,8 +195,8 @@ function toObjCValue(
);
return !isRequired
? `(p == nil ? folly::none : folly::make_optional(${namespacedStructName}(p)))`
: `${namespacedStructName}(p)`;
? `(${value} == nil ? folly::none : folly::make_optional(${namespacedStructName}(${value})))`
: `${namespacedStructName}(${value})`;
default:
(typeAnnotation.type: empty);
throw new Error(