From 9f97e488151eae7e1f054b55f9c2ed382bad622c Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 28 Aug 2021 06:51:44 +0800 Subject: [PATCH] bugfix: types.NewInterfaceType not Complete --- persist.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/persist.go b/persist.go index b9a468e2..c4652270 100644 --- a/persist.go +++ b/persist.go @@ -80,7 +80,9 @@ func fromPersistInterface(ctx *persistPkgCtx, t pobj) *types.Interface { embeddeds[i] = fromPersistType(ctx, t) } } - return types.NewInterfaceType(mthds, embeddeds) + i := types.NewInterfaceType(mthds, embeddeds) + ctx.intfs = append(ctx.intfs, i) + return i } func toPersistStruct(t *types.Struct) interface{} { @@ -544,6 +546,7 @@ func fromPersistPkg(ctx *persistPkgCtx, pkg *persistPkgRef) *PkgRef { ctx.pkg = types.NewPackage(pkg.PkgPath, pkg.Name) ctx.scope = ctx.pkg.Scope() ctx.checks = nil + ctx.intfs = nil var pkgf *pkgFingerp if pkg.Fingerp != "" { pkgf = &pkgFingerp{files: pkg.Files, fingerp: pkg.Fingerp} @@ -574,6 +577,7 @@ type persistPkgState struct { pkg *types.Package scope *types.Scope checks []*types.TypeName + intfs []*types.Interface } type persistPkgCtx struct { @@ -588,6 +592,9 @@ func (ctx *persistPkgCtx) check() { panic("type not found - " + ctx.pkg.Path() + "." + c.Name()) } } + for _, i := range ctx.intfs { + i.Complete() + } } func (ctx *persistPkgCtx) ref(pkgPath, name string) *types.Named {