Nenhuma descrição

1234567891011121314151617181920212223242526
  1. package main
  2. import "fmt"
  3. // START OMIT
  4. type P[T any] struct{}
  5. func (p *P[T]) Say[S any](v S) { fmt.Println(v) }
  6. type T struct{}
  7. func (t *T) Say[S any](v S) { fmt.Println(v) }
  8. func main() {
  9. var t T
  10. t.Say[int](1)
  11. /** output:
  12. method.go:8:19: methods cannot have type parameters
  13. method.go:8:20: invalid AST: method must have no type parameters
  14. method.go:12:16: methods cannot have type parameters
  15. method.go:12:17: invalid AST: method must have no type parameters
  16. */
  17. }
  18. // END OMIT