aboutsummaryrefslogtreecommitdiff
path: root/test/method1.go
AgeCommit message (Collapse)Author
2022-09-27cmd/compile: use "method T.m already declared" for method redeclaration errorsRobert Griesemer
Compromise between old compiler error "T.m redeclared in this block" (where the "in this block" is not particularly helpful) and the old type-checker error "method m already declared for type T ...". In the case where we have position information for the original declaration, the error message is "method T.m already declared at <position>". The new message is both shorter and more precise. For #55326. Change-Id: Id4a7f326fe631b11db9e8030eccb417c72d6c7db Reviewed-on: https://go-review.googlesource.com/c/go/+/435016 Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
2016-03-17cmd/compile: ignore receiver parameters in EqtypeMatthew Dempsky
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>
2012-02-23test: commentary for [h-m]*.goRob Pike
R=golang-dev, gri CC=golang-dev https://golang.org/cl/5674112
2012-02-16test: use testlib (final 61)Russ Cox
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5671080
2011-01-21test: s/float/float64/Ian Lance Taylor
Otherwise gccgo gives an extra error message not matched by errchk. R=adg, rsc CC=golang-dev https://golang.org/cl/4053042
2010-09-04test: remove semiocolons.Rob Pike
The ken directory is untouched so we have some examples with explicit semis. R=gri CC=golang-dev https://golang.org/cl/2157041
2009-08-21Enable these tests. Fix divconst.go and modconst.go toIan Lance Taylor
compile with the current compiler. Adjust expected error message in method1.go to match 6g output. R=rsc DELTA=9 (2 added, 5 deleted, 2 changed) OCL=33674 CL=33682
2009-08-17fix up some irregular indentationRob Pike
R=rsc OCL=33382 CL=33391
2009-01-20delete exportRuss Cox
TBR=r OCL=23121 CL=23127
2009-01-16convert tests; nothing interesting.Russ Cox
R=r OCL=23012 CL=23014
2008-11-11Recognize gccgo error messages. This uses GCCGO_ERROR, whichIan Lance Taylor
is recognized by the gccgo testsuite but is ignored by the errchk script used with 6g. method1.go:7:1: error: redefinition of 'M': parameter types changed method1.go:6:1: note: previous definition of 'M' was here method1.go:10:1: error: redefinition of 'f': parameter types changed method1.go:9:1: note: previous definition of 'f' was here method1.go:13:1: error: redefinition of 'g': parameter names changed method1.go:12:1: note: previous definition of 'g' was here R=rsc DELTA=5 (0 added, 0 deleted, 5 changed) OCL=18962 CL=19058
2008-10-24fix method function type compare bug (again)Russ Cox
R=ken OCL=17819 CL=17819