Skip to content

Commit

Permalink
Fix recursive definition in SupportStructures.k (#4035)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
drganjoo and Fahad Zubair authored Feb 25, 2025
1 parent e394ad8 commit 0f215bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ class SerializeImplGenerator(private val codegenContext: CodegenContext) {
}
""",
"Shape" to shape, "body" to block, *SupportStructures.codegenScope,
*RuntimeType.preludeScope,
)
}

Expand All @@ -578,6 +579,7 @@ class SerializeImplGenerator(private val codegenContext: CodegenContext) {
}
""",
"Shape" to shape, "body" to block, *SupportStructures.codegenScope,
*RuntimeType.preludeScope,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object SupportStructures {

val codegenScope =
arrayOf(
*RuntimeType.preludeScope,
"ConfigurableSerde" to configurableSerde(),
"SerializeConfigured" to serializeConfigured(),
"ConfigurableSerdeRef" to configurableSerdeRef(),
Expand Down Expand Up @@ -54,7 +53,7 @@ object SupportStructures {
"serde" to serde,
"SerializeConfigured" to serializeConfigured(),
"SerializationSettings" to serializationSettings(),
*codegenScope,
*RuntimeType.preludeScope,
)
}

Expand All @@ -78,7 +77,7 @@ object SupportStructures {
"serde" to serde,
"SerializeConfigured" to serializeConfigured(),
"SerializationSettings" to serializationSettings(),
*codegenScope,
*RuntimeType.preludeScope,
)
}

Expand Down Expand Up @@ -150,7 +149,7 @@ object SupportStructures {
}
""",
"serde" to CargoDependency.Serde.toType(),
*codegenScope,
*RuntimeType.preludeScope,
)
}

Expand Down Expand Up @@ -196,7 +195,7 @@ object SupportStructures {
"ConfigurableSerdeRef" to configurableSerdeRef(),
"SerializeConfigured" to serializeConfigured(),
"serde" to CargoDependency.Serde.toType(),
*codegenScope,
*RuntimeType.preludeScope,
)
}

Expand Down

0 comments on commit 0f215bb

Please sign in to comment.