Skip to content

Commit

Permalink
Fix Promise argument assertion to take into account executorTokenOffset.
Browse files Browse the repository at this point in the history
Summary:In the code that extracts and validates arguments from a `ReactMethod`, there is verification that if a method contains a Promise in it's list of arguments that it must come last. This fix makes sure that the `executorTokenOffset` is taken into account when asserting that condition.
Closes #6633

Differential Revision: D3143207

fb-gh-sync-id: ae9ebd9d829f88993f9951c4cb2452b3f7618476
fbshipit-source-id: ae9ebd9d829f88993f9951c4cb2452b3f7618476
  • Loading branch information
skevy authored and Facebook Github Bot 5 committed Apr 6, 2016
1 parent c0108a2 commit e27a27b
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -189,7 +189,8 @@ private ArgumentExtractor[] buildArgumentExtractors(Class[] paramTypes) {

ArgumentExtractor[] argumentExtractors = new ArgumentExtractor[paramTypes.length - executorTokenOffset];
for (int i = 0; i < paramTypes.length - executorTokenOffset; i += argumentExtractors[i].getJSArgumentsNeeded()) {
Class argumentClass = paramTypes[i + executorTokenOffset];
int paramIndex = i + executorTokenOffset;
Class argumentClass = paramTypes[paramIndex];
if (argumentClass == Boolean.class || argumentClass == boolean.class) {
argumentExtractors[i] = ARGUMENT_EXTRACTOR_BOOLEAN;
} else if (argumentClass == Integer.class || argumentClass == int.class) {
Expand All @@ -205,7 +206,7 @@ private ArgumentExtractor[] buildArgumentExtractors(Class[] paramTypes) {
} else if (argumentClass == Promise.class) {
argumentExtractors[i] = ARGUMENT_EXTRACTOR_PROMISE;
Assertions.assertCondition(
i == paramTypes.length - 1, "Promise must be used as last parameter only");
paramIndex == paramTypes.length - 1, "Promise must be used as last parameter only");
mType = METHOD_TYPE_REMOTE_ASYNC;
} else if (argumentClass == ReadableMap.class) {
argumentExtractors[i] = ARGUMENT_EXTRACTOR_MAP;
Expand Down Expand Up @@ -361,7 +362,7 @@ public void onReactBridgeInitialized(ReactBridge bridge) {
public void onCatalystInstanceDestroy() {
// do nothing
}

@Override
public boolean supportsWebWorkers() {
return false;
Expand Down

0 comments on commit e27a27b

Please sign in to comment.