Skip to content

Conversation

@ianbotsf
Copy link
Contributor

Issue #

Resolves #428

Description of changes

Calls within nested DSL functions will resolve an implicit receiver from anywhere up the hierarchy, enabling bad calls like this one:

CreateBucketRequest {
    bucket = "foo"
    grantRead = "bar"
    createBucketConfiguration {
        grantRead = "baz" // Should be prohibited
    }
}

In the above example, setting grantRead from within createBucketConfiguration should be prohibited because grantRead is a member of CreateBucketRequest.Builder, not CreateBucketConfiguration.Builder.

This change introduces a new DSL marker annotation @SdkDsl which is applied to every codegenned structure builder. Code like the above example now fails to compile.

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

@ianbotsf ianbotsf requested a review from a team as a code owner April 11, 2024 18:17
@ianbotsf ianbotsf merged commit 9e6a3f6 into main Apr 16, 2024
@ianbotsf ianbotsf deleted the feat-dsl-markers branch April 16, 2024 16:54
sullis pushed a commit to sullis/smithy-kotlin that referenced this pull request Jun 3, 2024
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.

Investigate adding DslMarker annotations to public APIs for better suggestions

2 participants