From 06dc5db75d4c2548c0187f34ce79389678be7ca0 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Thu, 22 Jan 2026 16:16:17 -0800 Subject: cmd/compile, go/*: move method type parameter checks from parsers to type checkers The parsers (cmd/compile/internal/syntax and go/parser) always accepted type parameters on methods for parser robustness but reported an error. With this change, the parsers accept the type parameters on methods, and then the type checkers (cmd/compile/internal/types2 and go/types) complain about them. Add test case for method type parameters when running the parsers only. Adjust some existing test cases as needed. This change is a necessary first step towards implementing generic methods but does not enable them. For #77273. Change-Id: I291fcf0aef0c917c74b32131c88b9e4ed71c5060 Reviewed-on: https://go-review.googlesource.com/c/go/+/738441 Reviewed-by: Mark Freeman LUCI-TryBot-Result: Go LUCI Reviewed-by: Robert Griesemer --- test/typeparam/issue50317.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/typeparam') diff --git a/test/typeparam/issue50317.go b/test/typeparam/issue50317.go index c33c4f061c..a7d0c38484 100644 --- a/test/typeparam/issue50317.go +++ b/test/typeparam/issue50317.go @@ -8,8 +8,8 @@ package p type S struct{} -func (S) _[_ any]() {} // ERROR "method must have no type parameters" +func (S) _[_ any]() {} // ERROR "method _ must have no type parameters" type _ interface { - m[_ any]() // ERROR "method must have no type parameters" + m[_ any]() // ERROR "interface method must have no type parameters" } -- cgit v1.3-6-g1900