]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: cleanup method symbol creation
authorMatthew Dempsky <mdempsky@google.com>
Thu, 5 Apr 2018 01:42:39 +0000 (18:42 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 5 Apr 2018 22:01:17 +0000 (22:01 +0000)
commit638f112d6982e83132051ccb4f0b27684b9c0f34
treedfd714cb183b8df6834ca70f1d1856cbfb9258c3
parent2e7e57770c71109cc036478c656309c41ddee143
cmd/compile: cleanup method symbol creation

There were multiple ad hoc ways to create method symbols, with subtle
and confusing differences between them. This CL unifies them into a
single well-documented encoding and implementation.

This introduces some inconsequential changes to symbol format for the
sake of simplicity and consistency. Two notable changes:

1) Symbol construction is now insensitive to the package currently
being compiled. Previously, non-exported methods on anonymous types
received different method symbols depending on whether the method was
local or imported.

2) Symbols for method values parenthesized non-pointer receiver types
and non-exported method names, and also always package-qualified
non-exported method names. Now they use the same rules as normal
method symbols.

The methodSym function is also now stricter about rejecting
non-sensical method/receiver combinations. Notably, this means that
typecheckfunc needs to call addmethod to validate the method before
calling declare, which also means we no longer emit errors about
redeclaring bogus methods.

Change-Id: I9501c7a53dd70ef60e5c74603974e5ecc06e2003
Reviewed-on: https://go-review.googlesource.com/104876
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/fmt_test.go
src/cmd/compile/internal/gc/bimport.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/typecheck.go
test/alias2.go