Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add synthetic box to root intEnums w/o a default #2053

Merged

Conversation

milesziemer
Copy link
Contributor

Primitive root shapes without the default trait have a synthetic box trait appplied when the shape is built in the loader (see

ModelInteropTransformer.patchShapeBeforeBuilding(defineShape, builder, events);
) if the shape would have a default of 0 in Smithy 1.0. Previously, this didn't include intEnum, so if you convert to 1.0, the intEnum which previously had no default in 2.0 will have a default of 0.

This commit updates ModelInteropTransformer to consider intEnum as a shape that has a default value in 1.0, so the loader applies the synthetic box trait to root intEnums.

Tests were updated to make sure box is added to root intEnums, and to fix some incorrect assertions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Primitive root shapes without the default trait have a synthetic
box trait appplied when the shape is built in the loader (see
https://github.com/smithy-lang/smithy/blob/d457aabb80feb4088caa3ac27d337b84e3ebc43d/smithy-model/src/main/java/software/amazon/smithy/model/loader/LoaderShapeMap.java#L366)
if the shape would have a default of 0 in Smithy 1.0.
Previously, this didn't include intEnum, so if you convert to
1.0, the intEnum which previously had no default in 2.0 will have
a default of 0.

This commit updates ModelInteropTransformer to consider intEnum as
a shape that has a default value in 1.0, so the loader applies the
synthetic box trait to root intEnums.

Tests were updated to make sure box is added to root intEnums, and
to fix some incorrect assertions.
@milesziemer milesziemer requested a review from a team as a code owner November 26, 2023 17:31
@milesziemer milesziemer merged commit 2bd81ac into smithy-lang:main Nov 26, 2023
10 checks passed
rchache pushed a commit to rchache/smithy that referenced this pull request Jan 2, 2024
Primitive root shapes without the default trait have a synthetic
box trait appplied when the shape is built in the loader (see
https://github.com/smithy-lang/smithy/blob/d457aabb80feb4088caa3ac27d337b84e3ebc43d/smithy-model/src/main/java/software/amazon/smithy/model/loader/LoaderShapeMap.java#L366)
if the shape would have a default of 0 in Smithy 1.0.
Previously, this didn't include intEnum, so if you convert to
1.0, the intEnum which previously had no default in 2.0 will have
a default of 0.

This commit updates ModelInteropTransformer to consider intEnum as
a shape that has a default value in 1.0, so the loader applies the
synthetic box trait to root intEnums.

Tests were updated to make sure box is added to root intEnums, and
to fix some incorrect assertions.
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