Skip to content

Conversation

@Lunderberg
Copy link
Contributor

Prior to this commit, the Array::Map member function could only be applied to nullable object types. This was due to the internal use of U() as the default value for initializing the output ArrayNode, where U is the return type of the mapping function. This default constructor is only available for nullable types, and would result in a compile-time failure for non-nullable types.

This commit replaces U() with ObjectRef() in Array::Map, removing this limitation. Since all items in the output array are overwritten before returning to the calling scope, initializing the output array with ObjectRef() does not violate type safety.

Prior to this commit, the `Array::Map` member function could only be
applied to nullable object types.  This was due to the internal use of
`U()` as the default value for initializing the output `ArrayNode`, where
`U` is the return type of the mapping function.  This default
constructor is only available for nullable types, and would result in
a compile-time failure for non-nullable types.

This commit replaces `U()` with `ObjectRef()` in `Array::Map`,
removing this limitation.  Since all items in the output array are
overwritten before returning to the calling scope, initializing the
output array with `ObjectRef()` does not violate type safety.
@Lunderberg
Copy link
Contributor Author

This change is split out from #16183 as an independent change for ease of review.

@Lunderberg Lunderberg requested a review from masahi June 18, 2024 19:00
@masahi masahi merged commit e520b9b into apache:main Jun 18, 2024
@Lunderberg Lunderberg deleted the container_array_map_with_non_nullable_type branch June 18, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants