aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2022-01-06 10:58:30 -0800
committerRobert Griesemer <gri@golang.org>2022-01-06 23:39:43 +0000
commit042548b1fdba21e351368e9f3ecd93059d09083f (patch)
tree479a06878234d9158fa1eafaabe4f115ab0b976d /test/typeparam
parentb9cae6f78f129bb3f1b3293da5375040f5c4f356 (diff)
downloadgo-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 'test/typeparam')
-rw-r--r--test/typeparam/issue50317.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/typeparam/issue50317.go b/test/typeparam/issue50317.go
new file mode 100644
index 0000000000..c33c4f061c
--- /dev/null
+++ b/test/typeparam/issue50317.go
@@ -0,0 +1,15 @@
+// errorcheck
+
+// Copyright 2022 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type S struct{}
+
+func (S) _[_ any]() {} // ERROR "method must have no type parameters"
+
+type _ interface {
+ m[_ any]() // ERROR "method must have no type parameters"
+}