| 1 |
package typeutil |
| 2 |
|
| 3 |
import ( |
| 4 |
"go/ast" |
| 5 |
"go/types" |
| 6 |
_ "unsafe" |
| 7 |
|
| 8 |
"golang.org/x/tools/go/types/typeutil" |
| 9 |
) |
| 10 |
|
| 11 |
type MethodSetCache = typeutil.MethodSetCache |
| 12 |
type Hasher = typeutil.Hasher |
| 13 |
|
| 14 |
func Callee(info *types.Info, call *ast.CallExpr) types.Object { |
| 15 |
return typeutil.Callee(info, call) |
| 16 |
} |
| 17 |
|
| 18 |
func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection { |
| 19 |
return typeutil.IntuitiveMethodSet(T, msets) |
| 20 |
} |
| 21 |
|
| 22 |
func MakeHasher() Hasher { |
| 23 |
return typeutil.MakeHasher() |
| 24 |
} |
| 25 |
|
| 26 |
type Map[V any] struct { |
| 27 |
m typeutil.Map |
| 28 |
} |
| 29 |
|
| 30 |
func (m *Map[V]) Delete(key types.Type) bool { return m.m.Delete(key) } |
| 31 |
func (m *Map[V]) At(key types.Type) (V, bool) { |
| 32 |
v := m.m.At(key) |
| 33 |
if v == nil { |
| 34 |
var zero V |
| 35 |
return zero, false |
| 36 |
} else { |
| 37 |
return v.(V), true |
| 38 |
} |
| 39 |
} |
| 40 |
func (m *Map[V]) Set(key types.Type, value V) { m.m.Set(key, value) } |
| 41 |
func (m *Map[V]) Len() int { return m.m.Len() } |
| 42 |
func (m *Map[V]) Iterate(f func(key types.Type, value V)) { |
| 43 |
ff := func(key types.Type, value any) { |
| 44 |
f(key, value.(V)) |
| 45 |
} |
| 46 |
m.m.Iterate(ff) |
| 47 |
|
| 48 |
} |
| 49 |
func (m *Map[V]) Keys() []types.Type { return m.m.Keys() } |
| 50 |
func (m *Map[V]) String() string { return m.m.String() } |
| 51 |
func (m *Map[V]) KeysString() string { return m.m.KeysString() } |
| 52 |
func (m *Map[V]) SetHasher(h typeutil.Hasher) { m.m.SetHasher(h) } |