Source file test/genmeth2.go
1 // skip 2 3 // Copyright 2026 The Go Authors. All rights reserved. 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file. 6 7 // Verify that generic methods work with pointer receivers. 8 9 package main 10 11 import "fmt" 12 13 type T struct {} 14 15 func (t *T) m[P any]() { 16 var x P 17 if got := fmt.Sprintf("%T", x); got != "int" { 18 panic(fmt.Sprintf("got %s, want int", got)) 19 } 20 } 21 22 func main() { 23 (&T{}).m[int]() 24 } 25