Repository navigation
fix(go): keep the receiver of methods on generic types - #812
kunalgoesbyken wants to merge 1 commit into
Conversation
`func (s *Stack[T]) Push` has a generic_type receiver, which the receiver
and type-name helpers did not unwrap. The method was minted without an
owner (`Push`, then `Push~2` for the next generic type), calls on the
receiver inside it were dropped, and `var s Stack[int]` or
`&Queue[K, V]{}` bound nothing, so no call into a generic type's methods
resolved.
Erase the type arguments wherever a Go type name is read: the receiver,
typed locals and fields, and composite literals.
🌱 graft blast radiusNothing outside this diff depends on it. 1 area changed; no indexed dependents at depth 2. Who knows this code — 1 person across 1 area
Ownership is git history over each area's own files, weighted towards recent work (120-day half-life). Merge commits and bots are dropped, and you are dropped from your own PR. A name with no Test signal per changed area — 1 ✗Reached = a node under a test path has a resolved edge into the changed symbol. It undercounts anything called indirectly — through a CLI, a spawned process or a dynamic import — so read a low ratio as “look here”, never as a coverage gate.
Open the interactive graph → — click an area to see its dependent symbols at file:line. |
Summary
A method on a generic type,
func (s *Stack[T]) Push(x T), has ageneric_typereceiver thatgoReceiverType(extract.ts) andgoReceiverTypeOf(bindings.ts) did not unwrap. The method was minted without an owner (Push, thenPush~2for the next generic type), calls on the receiver inside it were dropped, andvar s Stack[int]or&Queue[K, V]{}bound nothing. No call into a generic type's methods resolved.Changes
bindings.ts:goTypeNamenow also erases type arguments (*Stack[int]becomesStack), andgoReceiverTypeOfand the composite literal branch ofhandleGouse it.extract.ts:goReceiverTypeunwrapsgeneric_typeafter the pointer.The method set belongs to the generic type, so every place that reads a Go type name erases the arguments.
Testing
On Windows 11 with Node 26:
test/graph-go-generics.test.ts(new): the methods keep theirStackandQueueowner and ids, the receiver call inside each resolves, andvar s Stack[int],&Queue[string, int]{}andNewStack[int]()each resolve to their own type'sPushand not the other's. Fails on main.test/graph*,blast*,ask*,generic*,depth*,resolve*andcovers*suites: 673 tests, 1 fail. The one failure isdiscoverWorkspaceChildren follows a symlinked child repo, a symlink permission error on Windows that fails the same way on main.tsc --noEmitpasses.Fixes #811