diff options
| author | Robert Griesemer <gri@golang.org> | 2022-01-06 10:58:30 -0800 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2022-01-06 23:39:43 +0000 |
| commit | 042548b1fdba21e351368e9f3ecd93059d09083f (patch) | |
| tree | 479a06878234d9158fa1eafaabe4f115ab0b976d /src/cmd/compile/internal/syntax/testdata | |
| parent | b9cae6f78f129bb3f1b3293da5375040f5c4f356 (diff) | |
| download | go-042548b1fdba21e351368e9f3ecd93059d09083f.tar.xz | |
cmd/compile: report type parameter error for methods only once
Move switch to enable method type parameters entirely
to the parser, by adding the mode AllowMethodTypeParams.
Ensure that the error messages are consistent.
Remove unnecessary code in the type checker.
Fixes #50317.
Change-Id: I4f3958722400bdb919efa4c494b85cf62f4002bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/376054
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/syntax/testdata')
| -rw-r--r-- | src/cmd/compile/internal/syntax/testdata/issue48382.go2 | 10 | ||||
| -rw-r--r-- | src/cmd/compile/internal/syntax/testdata/tparams.go2 | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/syntax/testdata/issue48382.go2 b/src/cmd/compile/internal/syntax/testdata/issue48382.go2 index 1e8f4b0ec6..c00fee6f82 100644 --- a/src/cmd/compile/internal/syntax/testdata/issue48382.go2 +++ b/src/cmd/compile/internal/syntax/testdata/issue48382.go2 @@ -4,12 +4,12 @@ package p -type _ func /* ERROR function type cannot have type parameters */ [ /* ERROR empty type parameter list */ ]() -type _ func /* ERROR function type cannot have type parameters */ [ x /* ERROR missing type constraint */ ]() -type _ func /* ERROR function type cannot have type parameters */ [P any]() +type _ func /* ERROR function type must have no type parameters */ [ /* ERROR empty type parameter list */ ]() +type _ func /* ERROR function type must have no type parameters */ [ x /* ERROR missing type constraint */ ]() +type _ func /* ERROR function type must have no type parameters */ [P any]() -var _ = func /* ERROR function literal cannot have type parameters */ [P any]() {} +var _ = func /* ERROR function literal must have no type parameters */ [P any]() {} type _ interface{ - m /* ERROR interface method cannot have type parameters */ [P any]() + m /* ERROR interface method must have no type parameters */ [P any]() } diff --git a/src/cmd/compile/internal/syntax/testdata/tparams.go2 b/src/cmd/compile/internal/syntax/testdata/tparams.go2 index 80e155bfe0..a9bd72cf2d 100644 --- a/src/cmd/compile/internal/syntax/testdata/tparams.go2 +++ b/src/cmd/compile/internal/syntax/testdata/tparams.go2 @@ -13,7 +13,7 @@ type t struct { } type t interface { t[a] - m /* ERROR method cannot have type parameters */ [_ _, /* ERROR mixed */ _]() + m /* ERROR method must have no type parameters */ [_ _, /* ERROR mixed */ _]() t[a, b] } |
