Skip to content

Commit

Permalink
bugfix: types.NewInterfaceType not Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Aug 27, 2021
1 parent 8fa1b8a commit 9f97e48
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} {
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -574,6 +577,7 @@ type persistPkgState struct {
pkg *types.Package
scope *types.Scope
checks []*types.TypeName
intfs []*types.Interface
}

type persistPkgCtx struct {
Expand All @@ -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 {
Expand Down

0 comments on commit 9f97e48

Please sign in to comment.