go/ssa: instantiate method wrappers before adapting receivers by cpunion · Pull Request #680 · golang/tools · GitHub
Skip to content

go/ssa: instantiate method wrappers before adapting receivers - #680

Open
cpunion wants to merge 2 commits into
golang:masterfrom
cpunion:codex/ssa-generic-method-receiver-upstream-20260908
Open

cpunion wants to merge 2 commits into
golang:masterfrom
cpunion:codex/ssa-generic-method-receiver-upstream-20260908

Conversation

@cpunion

@cpunion cpunion commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

When a generic function's method expression is specialized, its
reconstructed selection signature has already adapted the receiver and
lost the method type parameters. Instantiating that signature with the
method's type arguments panics in go/types.

Instantiate the declared method's signature before adapting its receiver,
then restore the selected receiver. Remove the unused selection signature
and the code that constructed it. The separate signature canonicalization
fix in CL 835365 is now in master and is not duplicated here.

Add regression cases for an ordinary function with a matching signature,
a pointer receiver, and a promoted method. Test both SSA builder modes.
Track the larger receiver-handling cleanup in golang/go#81708.

Verified with go test ./go/ssa/... and, in the gopls module,
go test -short ./internal/test/marker on Go 1.27.2 darwin/arm64.

Fixes golang/go#81385

@gopherbot

Copy link
Copy Markdown
Contributor

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 1: Code-Review+1 Commit-Queue+1

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

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-09-18T18:14:32Z","revision":"4c91ba82c258de55341a0e3cf0f318a7300b81df"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 1: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_4809514>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 1:

This CL has failed the run. Reason:

Tryjob golang/try/x_tools-gotip-linux-arm64_debian13 has failed with summary (view all results):


To reproduce, try gomote repro 8670299285755254001.

Additional links for debugging:


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

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/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Mark Freeman:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 1: -Code-Review

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@cpunion
cpunion force-pushed the codex/ssa-generic-method-receiver-upstream-20260908 branch from 9473e31 to 339909a Compare September 23, 2026 18:02
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 339909a) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/828905.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Jie Li:

Patch Set 2:

(3 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 3: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-09-23T19:51:03Z","revision":"bebc2ebab875fd63a7c5125c1c04ab11e1f48ecc"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 3: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_4809514>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 3: Commit-Queue+1

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-09-24T15:17:37Z","revision":"bebc2ebab875fd63a7c5125c1c04ab11e1f48ecc"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 3: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_4809514>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 3:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alex Putman:

Patch Set 3:

(2 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@cpunion
cpunion force-pushed the codex/ssa-generic-method-receiver-upstream-20260908 branch from 339909a to 66311af Compare September 24, 2026 19:16
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 66311af) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/828905.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Jie Li:

Patch Set 4:

(5 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Alan Donovan:

Patch Set 4:

(7 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@cpunion
cpunion force-pushed the codex/ssa-generic-method-receiver-upstream-20260908 branch from 66311af to 0399027 Compare October 9, 2026 07:42
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 0399027) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/828905.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Jie Li:

Patch Set 5:

(7 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Peter Weinberger:

Patch Set 5:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@cpunion
cpunion force-pushed the codex/ssa-generic-method-receiver-upstream-20260908 branch from 0399027 to d17ab50 Compare October 21, 2026 00:50
When a generic function method expression is specialized, its reconstructed selection signature has already adapted the receiver and lost the method type parameters. Instantiate the selected method object signature first, then restore the selected receiver.

Keep instantiated method signatures out of the canonical type cache. Signature identity ignores receivers, so caching a method signature can cause an ordinary function instance to acquire a receiver and panic while building its instantiation wrapper.

Split regression coverage for ordinary functions, pointer receivers, and promoted methods. Test both generic builder modes and document the planned receiver handling refactor.

Fixes golang/go#81385
@cpunion
cpunion force-pushed the codex/ssa-generic-method-receiver-upstream-20260908 branch from d17ab50 to 8c86f84 Compare October 21, 2026 00:56
@gopherbot

Copy link
Copy Markdown
Contributor

Message from Jie Li:

Patch Set 5:

(1 comment)

Pushed d17ab50 and rebased onto current master. go test ./go/ssa/... and go test -short ./internal/test/marker (in gopls) pass with Go 1.27.2. Could someone rerun TryBots?


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 8c86f84) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/tools/+/828905.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Peter Weinberger:

Patch Set 6: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 6:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-10-24T22:09:20Z","revision":"833a750c337967837c09211d06441ab5ba734615"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Peter Weinberger:

Patch Set 6: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_5260>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 6:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/828905.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x/tools/go/ssa: panic building a generic method expression inside an instantiated function

2 participants