LookupInterface returns the underlying interface definition of the given interface name.
(name string)
| 56 | // LookupInterface returns the underlying interface definition of the |
| 57 | // given interface name. |
| 58 | func (r Registry) LookupInterface(name string) (*types.Interface, *types.TypeParamList, error) { |
| 59 | obj := r.SrcPkg().Types.Scope().Lookup(name) |
| 60 | if obj == nil { |
| 61 | return nil, nil, stackerr.NewStackErr(fmt.Errorf("interface not found: %s", name)) |
| 62 | } |
| 63 | |
| 64 | if !types.IsInterface(obj.Type()) { |
| 65 | return nil, nil, fmt.Errorf("%s (%s) is not an interface", name, obj.Type()) |
| 66 | } |
| 67 | |
| 68 | var tparams *types.TypeParamList |
| 69 | named, ok := obj.Type().(*types.Named) |
| 70 | if ok { |
| 71 | tparams = named.TypeParams() |
| 72 | } |
| 73 | |
| 74 | return obj.Type().Underlying().(*types.Interface).Complete(), tparams, nil |
| 75 | } |
| 76 | |
| 77 | // MethodScope returns a new MethodScope. |
| 78 | func (r *Registry) MethodScope() *MethodScope { |
no test coverage detected