Skip to content

fix(codemodel-foundation): marshal AnnotationValue.Value variants as real registered types#116

Merged
deer merged 1 commit into
mainfrom
annotation_value_cleanup
Jul 10, 2026
Merged

fix(codemodel-foundation): marshal AnnotationValue.Value variants as real registered types#116
deer merged 1 commit into
mainfrom
annotation_value_cleanup

Conversation

@deer

@deer deer commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

AnnotationValue.Value (Literal, ClassRef, EnumConstant, Nested, Array) was marshalled through hand-rolled toValue/fromValue helpers that converted each variant to a raw Object for serialization. The conversion was asymmetric: ClassRef serialized to a bare TypeName and EnumConstant serialized to a formatted "Type.CONSTANT" string, but the deserialize direction (toValue) had no matching cases for either, so both silently came back as a Value.Literal after an unmarshal, losing their real type and, for EnumConstant, the type name and constant name as separate fields.

Each Value variant is now its own registered marshalled record, using @Unmarshal/@Marshal methods and Marshalling.register, the same pattern PersonRecord already demonstrates in base-marshalling's own test suite for a plain record with no Trait/Composite involved. AnnotationValue itself now marshals value as a plain Marshalled<Value> instead of routing through the raw-Object helpers, which are removed entirely.

The bug was never caught because the only marshalling round-trip test touching AnnotationValue (MarshallingTests#shouldMarshallAndTransportAndUnmarshallAnnotationTypeUsage) only ever exercised Value.Literal, the one variant where the raw-Object round-trip happened to work. Added dedicated round-trip tests for the other four variants.

@deer deer merged commit 2e03d36 into main Jul 10, 2026
1 check passed
@deer deer deleted the annotation_value_cleanup branch July 10, 2026 06:01
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.

1 participant