1
0
mirror of https://github.com/golang/go synced 2024-11-26 10:18:12 -07:00

[dev.typeparams] cmd/compile: clarify comment about checking reflect.Method in usemethod

Followup discussion in CL 330670.

Change-Id: Icec2d5d5715666a6967e18ac9ab3d802b47569da
Reviewed-on: https://go-review.googlesource.com/c/go/+/330830
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2021-06-25 14:01:54 +07:00
parent ed647b16d0
commit d417b8cf87

View File

@ -958,9 +958,8 @@ func usemethod(n *ir.CallExpr) {
return return
} }
// Note: Don't rely on Field.Type.String() since its formatting depends on multiple factors // Check that first result type is "reflect.Method". Note that we have to check sym name and sym package
// (including global variables such as numImports - was issue #19028). // separately, as we can't check for exact string "reflect.Method" reliably (e.g., see #19028 and #38515).
// Also need to check for reflect package itself (see Issue #38515).
if s := t.Results().Field(0).Type.Sym(); s != nil && s.Name == "Method" && types.IsReflectPkg(s.Pkg) { if s := t.Results().Field(0).Type.Sym(); s != nil && s.Name == "Method" && types.IsReflectPkg(s.Pkg) {
ir.CurFunc.SetReflectMethod(true) ir.CurFunc.SetReflectMethod(true)
// The LSym is initialized at this point. We need to set the attribute on the LSym. // The LSym is initialized at this point. We need to set the attribute on the LSym.