1
0
mirror of https://github.com/golang/go synced 2024-10-04 23:21:20 -06:00
go/src/cmd
Matthew Dempsky b2b5e779f5 cmd/compile: ignore receiver parameters in Eqtype
Receiver parameters generally aren't relevant to the function
signature type. In particular:

  1. When checking whether a type's method implements an interface's
     method, we specifically want to ignore the receiver parameters,
     because they'll be different.

  2. When checking interface type equality, interface methods always
     use the same "fakethis" *struct{} type as their receiver.

  3. Finally, method expressions and method values degenerate into
     receiver-less function types.

The only case where we care about receiver types matching is in
addmethod, which is easily handled by adding an extra Eqtype check of
the receiver parameters. Also, added a test for this, since
(surprisingly) there weren't any.

As precedence, go/types.Identical ignores receiver parameters when
comparing go/types.Signature values.

Notably, this allows us to slightly simplify the "implements"
function, which is used for checking whether type/interface t
implements interface iface. Currently, cmd/compile actually works
around Eqtype's receiver parameter checking by creating new throwaway
TFUNC Types without the receiver parameter.

(Worse, the compiler currently only provides APIs to build TFUNC Types
from Nod syntax trees, so building those throwaway types also involves
first building throwaway syntax trees.)

Passes toolstash -cmp.

Change-Id: Ib07289c66feacee284e016bc312e8c5ff674714f
Reviewed-on: https://go-review.googlesource.com/20602
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-17 00:38:15 +00:00
..
addr2line cmd/addr2line: simplify windows test 2015-06-17 14:23:20 +00:00
api all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
asm cmd/compile: convert data siz to int 2016-03-14 20:22:21 +00:00
cgo cmd/cgo: add C.CBytes 2016-03-16 23:22:10 +00:00
compile cmd/compile: ignore receiver parameters in Eqtype 2016-03-17 00:38:15 +00:00
cover all: single space after period. 2016-03-02 00:13:47 +00:00
dist cmd/dist: build bootstrap toolchain with -l 2016-03-14 21:30:33 +00:00
doc all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
fix all: single space after period. 2016-03-02 00:13:47 +00:00
go testing: implement 'Unordered Output' in Examples. 2016-03-09 04:34:41 +00:00
gofmt all: single space after period. 2016-03-02 00:13:47 +00:00
internal cmd/internal/obj/x86: estimate text size 2016-03-16 23:27:19 +00:00
link cmd/compile: compute second method type at runtime 2016-03-15 19:57:40 +00:00
nm all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
objdump cmd/objdump: skip TestDisasm* for mips64{,le} 2015-09-10 18:27:09 +00:00
pack all: extract "can I exec?" check from tests into internal/testenv 2015-06-16 18:07:36 +00:00
pprof cmd/pprof: fix crash with invalid source 2016-03-13 20:38:16 +00:00
trace all: make copyright headers consistent with one space after period 2016-03-01 23:34:33 +00:00
vet cmd/vet: added some missing copylock checks 2016-03-16 05:12:48 +00:00
yacc Rewrite leftover references to plan9.bell-labs.com to 9p.io. 2016-03-06 07:07:01 +00:00