Skip to content

fix(golang): correct receiver type resolution in selector parsing#162

Merged
Duslia merged 2 commits intocloudwego:mainfrom
wzekin:fix/receiver-type-resolution
Feb 14, 2026
Merged

fix(golang): correct receiver type resolution in selector parsing#162
Duslia merged 2 commits intocloudwego:mainfrom
wzekin:fix/receiver-type-resolution

Conversation

@wzekin
Copy link
Contributor

@wzekin wzekin commented Feb 14, 2026

  • Fix receiver type resolution by using m.Signature().Recv().Type() instead of sel.Recv()
  • Add test case for struct method resolution

What type of PR is this?

fix

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

修复 method call 中,receiver 解析错误的问题

  • 在解析 receiver 的时候,直接使用了 sel 中的 type.Type,但如果 method 是通过引用 sub struct 调用的,此时应该返回 sub struct,而不是 sel 中的 type
  • 修复后,直接使用 type.Func 中 receiver 的类型,此处的类型一定是正确的

修复前,DFunction 的 receiver 是 MyStruct
修复后,DFunction 的 receiver 是 MyStructD

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

- Fix receiver type resolution by using m.Signature().Recv().Type() instead of sel.Recv()
- Add test case for struct method resolution
@Duslia Duslia merged commit 486662c into cloudwego:main Feb 14, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments