Skip to content

Commit e9ca1db

Browse files
stephentoubCopilot
andcommitted
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/permission_decision_no_result.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ func (PermissionDecisionNoResult) Kind() PermissionDecisionKind {
1515
return PermissionDecisionKind("no-result")
1616
}
1717

18-
func (PermissionDecisionNoResult) permissionDecisionKind() PermissionDecisionKind {
19-
return PermissionDecisionKind("no-result")
20-
}
21-
2218
// MarshalJSON emits {"kind":"no-result"} for serialization symmetry with
2319
// the other PermissionDecision variants. The SDK normally suppresses this
2420
// value before it reaches the wire, but a stable representation is useful

0 commit comments

Comments
 (0)