Commit e9ca1db
Scope down Go discriminator-method collision detection
The previous change to `goDiscriminatorMethodName` over-broadly flagged
collisions whenever the discriminator property's natural Go name matched the
chosen method name, even on multi-variant unions where the discriminator field
is elided or renamed to `Discriminator` on the emitted variant structs.
The result was 98 unnecessary `Kind()` -> `xxxKind()` method renames across
8 multi-variant unions (PermissionPromptRequest, PermissionDecision,
AgentRegistrySpawnResult, SlashCommandInvocationResult, UserToolSessionApproval,
PermissionsLocationsAddToolApprovalDetails, and the two ApproveFor* variants).
The real natural-name collision case is when the variant struct is a
pre-existing type (already in `ctx.generatedNames`) that retained the
discriminator as a struct field with its natural Go name -- e.g.,
`SessionListEntry`'s `LocalSessionMetadataValue.IsRemote bool` field, which
would clash with an exported `IsRemote() bool` interface method on the union.
This commit narrows the natural-name check to that pre-existing-variant case,
leaving the independent `Discriminator`-rename collision clause unchanged.
Also drops the now-dead `permissionDecisionKind()` helper from the
hand-written `permission_decision_no_result.go`.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 7ca801f commit e9ca1db
6 files changed
Lines changed: 350 additions & 346 deletions
File tree
- go/rpc
- scripts/codegen
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | 18 | | |
23 | 19 | | |
24 | 20 | | |
| |||
0 commit comments