From 6dd2032b3680b6fe6a8f91cfa4c5ed18f7b702a2 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Mon, 20 Jul 2026 17:15:40 -0400 Subject: [PATCH 1/3] fix(kotlin): forbid enum case names equal to the enum type name (#1815) Co-Authored-By: gpt-5.6-sol via pi --- .../src/language/Kotlin/KotlinRenderer.ts | 4 ++-- .../kotlin-enum-class-case-collision.json | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test/inputs/json/priority/kotlin-enum-class-case-collision.json diff --git a/packages/quicktype-core/src/language/Kotlin/KotlinRenderer.ts b/packages/quicktype-core/src/language/Kotlin/KotlinRenderer.ts index a39af4d0fc..d4bf50cd2a 100644 --- a/packages/quicktype-core/src/language/Kotlin/KotlinRenderer.ts +++ b/packages/quicktype-core/src/language/Kotlin/KotlinRenderer.ts @@ -57,9 +57,9 @@ export class KotlinRenderer extends ConvenienceRenderer { protected forbiddenForEnumCases( _e: EnumType, - _enumName: Name, + enumName: Name, ): ForbiddenWordsInfo { - return { names: [], includeGlobalForbidden: true }; + return { names: [enumName], includeGlobalForbidden: true }; } protected forbiddenForUnionMembers( diff --git a/test/inputs/json/priority/kotlin-enum-class-case-collision.json b/test/inputs/json/priority/kotlin-enum-class-case-collision.json new file mode 100644 index 0000000000..6fe2377c14 --- /dev/null +++ b/test/inputs/json/priority/kotlin-enum-class-case-collision.json @@ -0,0 +1,22 @@ +[ + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" }, + { "category": " " }, + { "category": "" } +] From 407baad7bbd839f4aab790edc9ac3725b782b372 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Mon, 20 Jul 2026 20:07:01 -0400 Subject: [PATCH 2/3] test(kotlinx): skip top-level-array enum-collision fixture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new priority fixture kotlin-enum-class-case-collision.json is a top-level JSON array, which the kotlinx renderer emits as `typealias TopLevel = JsonArray` — invalid Kotlin, since kotlinx's JsonArray takes no type arguments. This is a pre-existing, documented kotlinx limitation (see the ~40 existing top-level-array entries in this same skipJSON block and the TODO in KotlinXRenderer.ts), unrelated to the enum-naming fix in this PR. The enum case/class name-collision fix lives in the shared KotlinRenderer base class and remains covered by the kotlin (klaxon) and kotlin-jackson fixture runs, which handle top-level arrays as `class TopLevel : ArrayList` and do run this fixture. Co-Authored-By: Claude --- test/languages.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/languages.ts b/test/languages.ts index 6bcfd43611..594dfda726 100644 --- a/test/languages.ts +++ b/test/languages.ts @@ -1465,6 +1465,7 @@ export const KotlinXLanguage: Language = { // Top-level arrays render as `typealias TopLevel = JsonArray`, // which doesn't compile — kotlinx's JsonArray takes no type // arguments (documented TODO in KotlinXRenderer.ts). + "kotlin-enum-class-case-collision.json", "bug863.json", "github-events.json", "optional-union.json", From 5ced9e84c98ba55c40de50bb844280ed1d7cfe6b Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Mon, 20 Jul 2026 21:19:11 -0400 Subject: [PATCH 3/3] fix CI: skip json-ts-csharp for top-level-array enum-collision fixture (#1815) The new priority JSON input kotlin-enum-class-case-collision.json is a top-level array. quicktype's TypeScript --just-types renderer collapses a top-level array's element type onto the top-level name itself instead of emitting an array alias, so the C# code generated from that intermediate TypeScript expects a JSON object and throws when run against the original array JSON. This is the same pre-existing top-level-array limitation already covered by ~70 other entries in skipTypeScriptTests; add this fixture alongside them. Co-Authored-By: gpt-5.6-sol via pi --- test/fixtures.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/fixtures.ts b/test/fixtures.ts index dece181ef6..7e98fba697 100644 --- a/test/fixtures.ts +++ b/test/fixtures.ts @@ -659,6 +659,7 @@ const skipTypeScriptTests = [ "optional-union.json", "pokedex.json", // Enums are screwed up: https://github.com/YousefED/typescript-json-schema/issues/186 "github-events.json", + "kotlin-enum-class-case-collision.json", "bug855-short.json", "bug863.json", "00c36.json",