/
githubmirror
/
go
Обзор
Документация
Войти
/
githubmirror
/
go
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/genmeth2.go
35 строк
652 B
Mark Freeman
internal/goexperiment: delete Flags.GenericMethods
15 июн 2026, 18:21
15 июн 2026, 18:21
012d142
Код
Авторство
О чём код?
// run // Copyright 2026 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. // Verify that generic methods work with pointer receivers. package main import "fmt" type T struct {} func (t *T) m[P any]() { var x P if got := fmt.Sprintf("%T", x); got != "int" { panic(fmt.Sprintf("got %s, want int", got)) } } type G[P any] struct {} func (g *G[P]) m[Q any]() { var p P var q Q if got := fmt.Sprintf("%T %T", p, q); got != "int bool" { panic(fmt.Sprintf("got %s, want int bool", got)) } } func main() { (&T{}).m[int]() (&G[int]{}).m[bool]() }