MCPcopy Create free account
hub / github.com/despiteallobjections/amigo / NewInterfaceType

Function NewInterfaceType

types/interface.go:33–54  ·  view source on GitHub ↗

NewInterfaceType returns a new interface for the given methods and embedded types. NewInterfaceType takes ownership of the provided methods and may modify their types by setting missing receivers.

(methods []*Func, embeddeds []Type)

Source from the content-addressed store, hash-verified

31// NewInterfaceType takes ownership of the provided methods and may modify their types
32// by setting missing receivers.
33func NewInterfaceType(methods []*Func, embeddeds []Type) *Interface {
34 if len(methods) == 0 && len(embeddeds) == 0 {
35 return &emptyInterface
36 }
37
38 // set method receivers if necessary
39 typ := (*Checker)(nil).newInterface()
40 for _, m := range methods {
41 if sig := m.typ.(*Signature); sig.recv == nil {
42 sig.recv = NewVar(m.pos, m.pkg, "", typ)
43 }
44 }
45
46 // sort for API stability
47 sortMethods(methods)
48
49 typ.methods = methods
50 typ.embeddeds = embeddeds
51 typ.complete = true
52
53 return typ
54}
55
56// check may be nil
57func (check *Checker) newInterface() *Interface {

Callers 8

initReflectFunction · 0.92
TestInstantiateEqualityFunction · 0.85
TestIssue5849Function · 0.85
TestIssue28282Function · 0.85
applyTypeFuncMethod · 0.85
ifaceMethod · 0.85
builder.goFile · 0.85
TestIsAliasFunction · 0.85

Calls 3

NewVarFunction · 0.85
sortMethodsFunction · 0.85
newInterfaceMethod · 0.80

Tested by 4

TestInstantiateEqualityFunction · 0.68
TestIssue5849Function · 0.68
TestIssue28282Function · 0.68
TestIsAliasFunction · 0.68