Repository navigation
Conversation
When package b declares an exported type alias "type T = a.T" for a non-interface type a.T defined in an imported package a, the unified IR linker does not export a.T's inline method bodies in b's export data. relocObj only walks a type's methods when the object is not an alias, and exportBody only re-exports an imported body if b itself inlined a call to it (fn.Inl.HaveDcl). As a result, a package c that imports b, but not a, cannot inline methods called through b.T. Fix this by indexing imported static method bodies by their receiver type symbol in readPackage (importTypeBodies). When relocObj relocates a top-level, local, exported type alias to an imported non-interface type, forward the aliased type's inline method bodies into b's export data. While relocating a forwarded body, also forward the inline bodies of imported functions and receiver types it references, including entries that were already relocated. Packages without such aliases export the same data as before. Alias chains also work: if c instead declares "type T = b.T", c.T resolves to a.T, so c forwards the bodies it read from b's export data and a package d that imports only c can inline them. TestInlineTypeAliasMethods covers this two-hop case.
57ccd1c to
83ce276
Compare
|
This PR (HEAD: 83ce276) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/853585. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/853585. |
|
Message from David Chase: Patch Set 1: Auto-Submit+1 Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/853585. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-10-26T00:24:59Z","revision":"b70ce5d8a6b6051e28a3031775f80c29c4936c92"} Please don’t reply on this GitHub thread. Visit golang.org/cl/853585. |
|
Message from David Chase: Patch Set 1: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_7061>) Please don’t reply on this GitHub thread. Visit golang.org/cl/853585. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/853585. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/853585. |
When package b declares an exported type alias "type T = a.T" for a
non-interface type a.T defined in an imported package a, the unified
IR linker does not export a.T's inline method bodies in b's export
data. relocObj only walks a type's methods when the object is not an
alias, and exportBody only re-exports an imported body if b itself
inlined a call to it (fn.Inl.HaveDcl). As a result, a package c that
imports b, but not a, cannot inline methods called through b.T.
Fix this by indexing imported static method bodies by their receiver
type symbol in readPackage (importTypeBodies). When relocObj relocates
a top-level, local, exported type alias to an imported non-interface
type, forward the aliased type's inline method bodies into b's export
data. While relocating a forwarded body, also forward the inline
bodies of imported functions and receiver types it references,
including entries that were already relocated. Packages without such
aliases export the same data as before.
Alias chains also work: if c instead declares "type T = b.T", c.T
resolves to a.T, so c forwards the bodies it read from b's export data
and a package d that imports only c can inline them.
TestInlineTypeAliasMethods covers this two-hop case.
Fixes #82474