Skip to content

Commit 0f215bb

Browse files
drganjooFahad Zubair
and
Fahad Zubair
authored
Fix recursive definition in SupportStructures.k (#4035)
This PR fixes a recursive definition issue in the `SupportStructures.kt` file where `codegenScope` was being used within its own dependent functions, creating a circular dependency. The issue specifically occurred in the `serializeRedacted()`, `sensitive()`, `configurableSerde()` and `serializeUnredacted()` functions where `codegenScope` was being included in the template parameters. The fix: - Removed the recursive usage of `codegenScope` - Instead, directly used `RuntimeType.preludeScope` where needed - This change maintains the same functionality while avoiding the circular dependency Before: ```kotlin *codegenScope // This created a recursive definition as codegenScope depends on these functions ``` After: ```kotlin *RuntimeType.preludeScope // Direct usage of prelude scope without recursion ``` Co-authored-by: Fahad Zubair <[email protected]>
1 parent e394ad8 commit 0f215bb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

codegen-serde/src/main/kotlin/software/amazon/smithy/rust/codegen/serde/SerializeImplGenerator.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ class SerializeImplGenerator(private val codegenContext: CodegenContext) {
556556
}
557557
""",
558558
"Shape" to shape, "body" to block, *SupportStructures.codegenScope,
559+
*RuntimeType.preludeScope,
559560
)
560561
}
561562

@@ -578,6 +579,7 @@ class SerializeImplGenerator(private val codegenContext: CodegenContext) {
578579
}
579580
""",
580581
"Shape" to shape, "body" to block, *SupportStructures.codegenScope,
582+
*RuntimeType.preludeScope,
581583
)
582584
}
583585
}

codegen-serde/src/main/kotlin/software/amazon/smithy/rust/codegen/serde/SupportStructures.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ object SupportStructures {
2323

2424
val codegenScope =
2525
arrayOf(
26-
*RuntimeType.preludeScope,
2726
"ConfigurableSerde" to configurableSerde(),
2827
"SerializeConfigured" to serializeConfigured(),
2928
"ConfigurableSerdeRef" to configurableSerdeRef(),
@@ -54,7 +53,7 @@ object SupportStructures {
5453
"serde" to serde,
5554
"SerializeConfigured" to serializeConfigured(),
5655
"SerializationSettings" to serializationSettings(),
57-
*codegenScope,
56+
*RuntimeType.preludeScope,
5857
)
5958
}
6059

@@ -78,7 +77,7 @@ object SupportStructures {
7877
"serde" to serde,
7978
"SerializeConfigured" to serializeConfigured(),
8079
"SerializationSettings" to serializationSettings(),
81-
*codegenScope,
80+
*RuntimeType.preludeScope,
8281
)
8382
}
8483

@@ -150,7 +149,7 @@ object SupportStructures {
150149
}
151150
""",
152151
"serde" to CargoDependency.Serde.toType(),
153-
*codegenScope,
152+
*RuntimeType.preludeScope,
154153
)
155154
}
156155

@@ -196,7 +195,7 @@ object SupportStructures {
196195
"ConfigurableSerdeRef" to configurableSerdeRef(),
197196
"SerializeConfigured" to serializeConfigured(),
198197
"serde" to CargoDependency.Serde.toType(),
199-
*codegenScope,
198+
*RuntimeType.preludeScope,
200199
)
201200
}
202201

0 commit comments

Comments
 (0)