]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile: stop mangling SelectorExpr.Sel for ODOTMETH
authorMatthew Dempsky <mdempsky@google.com>
Sun, 27 Dec 2020 02:56:36 +0000 (18:56 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 28 Dec 2020 07:44:07 +0000 (07:44 +0000)
commite6c973198d9f8e68e4dce8637e2d1492032ce939
treeeabf85d6087243281a55a98983db4e11b7803fb5
parent135ce1c485d0563d285f47a748a6d56594571a91
[dev.regabi] cmd/compile: stop mangling SelectorExpr.Sel for ODOTMETH

ODOTMETH is unique among SelectorExpr expressions, in that Sel gets
mangled so that it no longer has the original identifier that was
selected (e.g., just "Foo"), but instead the qualified symbol name for
the selected method (e.g., "pkg.Type.Foo"). This is rarely useful, and
instead results in a lot of compiler code needing to worry about
undoing this change.

This CL changes ODOTMETH to leave the original symbol in place. The
handful of code locations where the mangled symbol name is actually
wanted are updated to use ir.MethodExprName(n).Sym() or (equivalently)
ir.MethodExprName(n).Func.Sym() instead.

Historically, the compiler backend has mistakenly used types.Syms
where it should have used ir.Name/ir.Funcs. And this change in
particular may risk breaking something, as the SelectorExpr.Sel will
no longer point at a symbol that uniquely identifies the called
method. However, I expect CL 280294 (desugar OCALLMETH into OCALLFUNC)
to have substantially reduced this risk, as ODOTMETH expressions are
now replaced entirely earlier in the compiler.

Passes toolstash -cmp.

Change-Id: If3c9c3b7df78ea969f135840574cf89e1d263876
Reviewed-on: https://go-review.googlesource.com/c/go/+/280436
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/ir/fmt.go
src/cmd/compile/internal/typecheck/expr.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/typecheck.go
src/cmd/compile/internal/types/fmt.go
test/fixedbugs/issue31053.dir/main.go