Skip to content

Commit ad4d2a3

Browse files
authored
misc: test union member name same as union (#1241)
1 parent cea7b1f commit ad4d2a3

File tree

1 file changed

+39
-0
lines changed
  • tests/compile/src/test/kotlin/software/amazon/smithy/kotlin/codegen

1 file changed

+39
-0
lines changed

tests/compile/src/test/kotlin/software/amazon/smithy/kotlin/codegen/SmithySdkTest.kt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,45 @@ class SmithySdkTest {
224224

225225
assertEquals(KotlinCompilation.ExitCode.OK, compilationResult.exitCode, compileOutputStream.toString())
226226
}
227+
228+
// https://github.com/smithy-lang/smithy-kotlin/issues/1129
229+
@Test
230+
fun `it compiles models with unions with members that have the same name as the union`() {
231+
val model = """
232+
namespace aws.sdk.kotlin.test
233+
234+
use aws.protocols#awsJson1_0
235+
use smithy.rules#operationContextParams
236+
use smithy.rules#endpointRuleSet
237+
use aws.api#service
238+
239+
@awsJson1_0
240+
@service(sdkId: "UnionOperationTest")
241+
service TestService {
242+
operations: [UnionOperation],
243+
version: "1"
244+
}
245+
246+
operation UnionOperation {
247+
input: UnionOperationRequest
248+
}
249+
250+
structure UnionOperationRequest {
251+
Union: Foo
252+
}
253+
254+
union Foo {
255+
foo: Boolean
256+
}
257+
258+
""".asSmithy()
259+
260+
val compileOutputStream = ByteArrayOutputStream()
261+
val compilationResult = compileSdkAndTest(model = model, outputSink = compileOutputStream, emitSourcesToTmp = Debug.emitSourcesToTemp)
262+
compileOutputStream.flush()
263+
264+
assertEquals(KotlinCompilation.ExitCode.OK, compilationResult.exitCode, compileOutputStream.toString())
265+
}
227266
}
228267

229268
/**

0 commit comments

Comments
 (0)