ssa: preserve package identity for unexported methods - #2258
Conversation
There was a problem hiding this comment.
Review summary
This is a well-targeted, correct fix. Qualifying an unexported method name with its declaring package path when the receiver package differs (MethodSymbolName) properly preserves Go's package-scoped identity for unexported methods, and the iMethodOf switch from bare-name to types.Id(pkg, name) comparison matches Go's interface-method identity semantics. Both symbol-producing sites (cl/import.go funcName and ssa/abitype.go abiUncommonMethods) route names through the same MethodSymbolName → FuncName pipeline and normalize via PathOf, so definition and reference symbols stay in sync. Test coverage is strong: unit tests for both MethodSymbolName and iMethodOf, plus an end-to-end fixture reproducing the collision, and the corresponding xfail.yaml entry (fixedbugs/issue24693.go) is correctly removed. The unchecked assertions (m.Obj().(*types.Func) on method-set selections, comma-ok elsewhere) are safe.
No blocking issues. Reviewers converged on minor/maintainability observations only.
Findings (non-blocking)
ssa/interface.go:53— removed// TODO(xsw): check signature. The removal looks intentional (interface method names are unique within an interface, so a signature check is unnecessary for correctness). Confirming this was an obsolete-cleanup rather than dropping a still-relevant concern.- Performance (informational, not a concern):
iMethodOfnow computestypes.Id(m.Pkg(), m.Name())per interface method, which allocates one string per method for unexported names (types.Idis allocation-free for exported names). Bounded and correct-by-design for a compiler codegen path; no change needed.
See inline comments for the two maintainability notes worth a short code comment.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
No main baseline exists yet; all metrics are marked Warning
|
Fixes the shared method-identity root cause behind GOROOT
fixedbugs/issue24693.go.Summary
Tests
go test ./ssa -count=1 -timeout=20mgo test ./cl -run "^TestRunAndTestFromTestgo/(abimethod|interface|embedunexport-1598)$" -count=1go test ./internal/build -run "^TestBuildPreservesUnexportedMethodIdentity$" -count=1fixedbugs/issue24693.gowith an empty xfail configurationMethodSymbolNameandiMethodOfbranches are each covered at 100%