Skip to content

Bug when using smithy-trait-codegen with @idRef #2476

Open
@msosnicki

Description

Generating a code for the following trait:

@trait
structure someTrait {
    @idRef(failWhenMissing: true)
    targetId: String
}

renders the following java code:

    /**
     * Creates a builder used to build a {@link SomeTrait}.
     */
    public SmithyBuilder<SomeTrait> toBuilder() {
        return builder().sourceLocation(getSourceLocation())
            .targetId(targetId);
    }

    public static Builder builder() {
        return new Builder();
    }

    /**
     * Builder for {@link SomeTrait}.
     */
    public static final class Builder extends AbstractTraitBuilder<SomeTrait, Builder> {private ShapeId targetId;

        private Builder() {}

        public Builder targetId(String targetId) {
            this.targetId = targetId;
            return this;
        }

        @Override
        public SomeTrait build() {
            return new SomeTrait(this);
        }
    }

which doesn't compile, it attempts to assign a String into a ShapeId field

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions