summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Rex <julian.rex@mapbox.com>2019-04-13 13:13:30 -0400
committerJulian Rex <julian.rex@mapbox.com>2019-04-17 16:21:41 -0400
commitd82b0b7caf469b68ae53ebbb5db34fb382f2efd4 (patch)
tree312e11cf4cd49b29b949d55134ba774ea9b3a41d
parent7e1ca02bb7f901cfc03888d54793aee138a4ebdf (diff)
downloadqtlocation-mapboxgl-upstream/jrex/analyzer-fixes.tar.gz
[ios] Fix analyzer fixupstream/jrex/analyzer-fixes
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.h2
-rw-r--r--platform/darwin/src/NSExpression+MGLAdditions.mm35
2 files changed, 17 insertions, 20 deletions
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.h b/platform/darwin/src/NSExpression+MGLAdditions.h
index a19ec1af2e..9ef6623068 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.h
+++ b/platform/darwin/src/NSExpression+MGLAdditions.h
@@ -190,7 +190,7 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionI
@return An initialized expression equivalent to `object`, suitable for use as
the value of a style layer attribute.
*/
-+ (instancetype)expressionWithMGLJSONObject:(id)object NS_SWIFT_NAME(init(mglJSONObject:));
++ (instancetype)expressionWithMGLJSONObject:(nullable id)object NS_SWIFT_NAME(init(mglJSONObject:));
/**
An equivalent Foundation object that can be serialized as JSON.
diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm
index fe2e5a0a31..026d8bec02 100644
--- a/platform/darwin/src/NSExpression+MGLAdditions.mm
+++ b/platform/darwin/src/NSExpression+MGLAdditions.mm
@@ -792,24 +792,19 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
} else if ([curveType isEqualToString:@"cubic-bezier"]) {
curveParameters = @[@"literal", [interpolationOptions subarrayWithRange:NSMakeRange(1, 4)]];
}
-
- NSAssert(curveParameters, @"curveParameters should be non-nil");
- if (curveParameters) {
- NSExpression *curveParameterExpression = [NSExpression expressionWithMGLJSONObject:curveParameters];
- argumentObjects = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
- NSExpression *inputExpression = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject];
- NSArray *stopExpressions = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
- NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:stopExpressions.count / 2];
- NSEnumerator *stopEnumerator = stopExpressions.objectEnumerator;
- while (NSNumber *key = stopEnumerator.nextObject) {
- NSExpression *valueExpression = stopEnumerator.nextObject;
- stops[key] = [NSExpression expressionWithMGLJSONObject:valueExpression];
- }
- NSExpression *stopExpression = [NSExpression expressionForConstantValue:stops];
- return [NSExpression expressionForFunction:@"mgl_interpolate:withCurveType:parameters:stops:"
- arguments:@[inputExpression, curveTypeExpression, curveParameterExpression, stopExpression]];
+ NSExpression *curveParameterExpression = [NSExpression expressionWithMGLJSONObject:curveParameters];
+ argumentObjects = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
+ NSExpression *inputExpression = [NSExpression expressionWithMGLJSONObject:argumentObjects.firstObject];
+ NSArray *stopExpressions = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
+ NSMutableDictionary *stops = [NSMutableDictionary dictionaryWithCapacity:stopExpressions.count / 2];
+ NSEnumerator *stopEnumerator = stopExpressions.objectEnumerator;
+ while (NSNumber *key = stopEnumerator.nextObject) {
+ NSExpression *valueExpression = stopEnumerator.nextObject;
+ stops[key] = [NSExpression expressionWithMGLJSONObject:valueExpression];
}
-
+ NSExpression *stopExpression = [NSExpression expressionForConstantValue:stops];
+ return [NSExpression expressionForFunction:@"mgl_interpolate:withCurveType:parameters:stops:"
+ arguments:@[inputExpression, curveTypeExpression, curveParameterExpression, stopExpression]];
} else if ([op isEqualToString:@"step"]) {
NSExpression *inputExpression = [NSExpression expressionWithMGLJSONObject:argumentObjects[0]];
NSArray *stopExpressions = [argumentObjects subarrayWithRange:NSMakeRange(1, argumentObjects.count - 1)];
@@ -1031,7 +1026,7 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
}
case NSKeyPathExpressionType: {
- NSArray *expressionObject = @[];
+ NSArray *expressionObject;
NSArray *keyPath = [self.keyPath componentsSeparatedByString:@"."];
for (NSString *pathComponent in keyPath) {
if (expressionObject) {
@@ -1042,7 +1037,9 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) {
}
NSAssert(expressionObject.count > 0, @"expressionObject should be non-empty");
- return expressionObject;
+
+ // Return a non-null value to quieten static analysis
+ return expressionObject ?: @[];
}
case NSFunctionExpressionType: {