Repository navigation
Conversation
…lbymchenry#2323) The Go typed-parameter receiver pattern is PascalCase-guarded, so `func (s *server)` yielded no receiver type and `s.service.AddItem()` was dropped. Add a receiver pattern anchored on `func (` that accepts unexported and generic receiver types; plain parameters keep the guard.
|
A note on overlap: I found #1954 after opening this. Its new parameter/receiver pattern also matches Measured on the same shallow clones (#1954 at
#1954 finds many more edges. Among the call sites it drops, these shapes resolve correctly on main:
So the two can go either way: this PR is a small, removal-free subset that can land on its own, and #1954 would supersede it. Happy to close this one if you'd rather take #1954. |
|
Thanks a lot for measuring #1954 on these repos: the alias and embedded-struct cases were real losses of correct edges. Both are fixed on the branch now: aliases like |
|
Thanks @GoDiao! Your receiver pattern landed in #2361, extended to plain parameters. One finding changed the shape of the fix. Applied alone on |
Fixes #2323.
Problem
matchGoFieldChainCallinfers the base receiver's type withinferLocalReceiverType. For a Go method receiver the only matching pattern was the typed-parameter one, which is PascalCase-guarded, sofunc (s *server)produced no type ands.service.AddItem()was dropped.Change
One new pattern in the Go branch of
localReceiverTypePatterns, anchored onfunc (:func (anchor already rules out the unrelatedident Typepairs the PascalCase guard protects against.func (c *cache[T])givescache).The resolved method is still validated by
resolveMethodOnType, as for every other inferred receiver.Tests
Added a case to the
Go field-chain receiver calls (#1276)block in__tests__/resolution.test.ts. It covers an unexported receiver (server) and a generic one (cache[T]); both fail before this change and pass after it.npm testlocally on macOS: everything passes exceptbundle-launcher.test.ts, which fails the same way onmainon this machine (Library not loaded: libnode.127.dylib, a local Node install issue).Impact on real repos
The numbers in #2323 were measured with this exact pattern added: +1,123 Go call edges on prometheus, +707 on etcd, +3,328 on harbor (
src/) and +542 on mattermost (server/). A random sample of 32 new edges checked against the source was all correct. Only 2 existing edges changed, both in mattermost, and both were previously wrong (for examplesrc.setin afileSrcmethod used to resolve tojsonSrc::set).