aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/walk
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2021-06-25 14:01:54 +0700
committerCuong Manh Le <cuong.manhle.vn@gmail.com>2021-06-26 08:22:31 +0000
commitd417b8cf87bd8e0f8362aa1cc9b7dadd221731c9 (patch)
tree5b3f2040fec29d20cf11f83295e2665b165333ed /src/cmd/compile/internal/walk
parented647b16d02da4571c22baac23c302f2d888b88b (diff)
downloadgo-d417b8cf87bd8e0f8362aa1cc9b7dadd221731c9.tar.gz
go-d417b8cf87bd8e0f8362aa1cc9b7dadd221731c9.zip
[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>
Diffstat (limited to 'src/cmd/compile/internal/walk')
-rw-r--r--src/cmd/compile/internal/walk/expr.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/walk/expr.go b/src/cmd/compile/internal/walk/expr.go
index d8bded8075..6928f2ac70 100644
--- a/src/cmd/compile/internal/walk/expr.go
+++ b/src/cmd/compile/internal/walk/expr.go
@@ -958,9 +958,8 @@ func usemethod(n *ir.CallExpr) {
return
}
- // Note: Don't rely on Field.Type.String() since its formatting depends on multiple factors
- // (including global variables such as numImports - was issue #19028).
- // Also need to check for reflect package itself (see Issue #38515).
+ // Check that first result type is "reflect.Method". Note that we have to check sym name and sym package
+ // separately, as we can't check for exact string "reflect.Method" reliably (e.g., see #19028 and #38515).
if s := t.Results().Field(0).Type.Sym(); s != nil && s.Name == "Method" && types.IsReflectPkg(s.Pkg) {
ir.CurFunc.SetReflectMethod(true)
// The LSym is initialized at this point. We need to set the attribute on the LSym.