internal/runtime: NewNamedInterface check exist

This commit is contained in:
visualfc
2024-12-17 21:36:51 +08:00
parent b4af70ada9
commit ce169163b9

View File

@@ -225,6 +225,12 @@ func Func(in, out []*Type, variadic bool) *FuncType {
}
func NewNamedInterface(pkgPath, name string) *InterfaceType {
named := pkgPath + "." + name
for _, typ := range rtypeList {
if typ.named == named {
return typ.InterfaceType()
}
}
ret := &struct {
abi.InterfaceType
u abi.UncommonType
@@ -246,6 +252,7 @@ func NewNamedInterface(pkgPath, name string) *InterfaceType {
PkgPath_: pkgPath,
},
}
rtypeList = append(rtypeList, &rtype{Type: &ret.Type, named: named})
return &ret.InterfaceType
}