You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/JsonSerializerGeneratorTest.kt
+12-23Lines changed: 12 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -39,10 +39,10 @@ class JsonSerializerGeneratorTest {
39
39
use aws.protocols#restJson1
40
40
41
41
union TestUnion {
42
-
unitMember: Unit,
43
-
dataMember: String
42
+
unitMember: Unit
44
43
}
45
44
45
+
// Empty unit struct that doesn't need serialization parameters
46
46
structure Unit {}
47
47
48
48
@http(uri: "/test", method: "POST")
@@ -370,19 +370,13 @@ class JsonSerializerGeneratorTest {
370
370
@Test
371
371
fun`union with unit struct doesn't cause unused variable warning`() {
372
372
// Regression test for https://github.com/smithy-lang/smithy-rs/issues/4308
373
-
//
374
-
// PROBLEM BEFORE FIX: JSON serializer generated `UnitMember(_inner)` but tried to use `inner`
375
-
// This caused compilation errors: "cannot find value `inner` in this scope"
376
-
//
377
-
// SOLUTION AFTER FIX: Generate `UnitMember(inner)` so variable name matches usage
378
-
// This test verifies the FIXED behavior compiles and works correctly
373
+
// This test ensures that union serialization with unit structs compiles without unused variable warnings.
379
374
val model =RecursiveShapeBoxer().transform(OperationNormalizer.transform(unionWithUnitStructModel))
380
375
381
376
val codegenContext = testCodegenContext(model)
382
377
val symbolProvider = codegenContext.symbolProvider
383
378
val project =TestWorkspace.testProject(symbolProvider)
384
379
385
-
// Generate the JSON serializer with our FIX applied
386
380
val jsonSerializer =
387
381
JsonSerializerGenerator(
388
382
codegenContext,
@@ -399,31 +393,26 @@ class JsonSerializerGeneratorTest {
Copy file name to clipboardExpand all lines: codegen-core/src/test/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/serialize/QuerySerializerGeneratorTest.kt
+13-16Lines changed: 13 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -25,17 +25,17 @@ class QuerySerializerGeneratorTest {
25
25
@Test
26
26
fun`union with unit struct doesn't cause unused variable warning`() {
27
27
// Regression test for https://github.com/smithy-lang/smithy-rs/issues/4308
28
-
//
29
-
// This test demonstrates the BEFORE/AFTER behavior for Query serialization
28
+
// This test ensures that Query serialization with unit structs compiles without unused variable warnings.
29
+
// Query serialization for unit structs generates empty blocks where the variable would be unused,
30
+
// so the fix uses '_inner' (with underscore prefix) to suppress the unused variable warning.
30
31
val model =
31
32
RecursiveShapeBoxer().transform(
32
33
OperationNormalizer.transform(
33
34
"""
34
35
namespace test
35
36
36
37
union TestUnion {
37
-
unitMember: Unit,
38
-
dataMember: String
38
+
unitMember: Unit
39
39
}
40
40
41
41
structure Unit {}
@@ -55,7 +55,6 @@ class QuerySerializerGeneratorTest {
55
55
val codegenContext = testCodegenContext(model)
56
56
val symbolProvider = codegenContext.symbolProvider
57
57
58
-
// Generate the Query serializer with our FIX applied
59
58
val parserSerializer =AwsQuerySerializerGenerator(codegenContext)
60
59
val operationGenerator = parserSerializer.operationInputSerializer(model.lookup("test#TestOp"))
61
60
@@ -69,29 +68,27 @@ class QuerySerializerGeneratorTest {
0 commit comments