Skip to content

Commit

Permalink
NewFuncWith bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jul 20, 2021
1 parent 86ace58 commit 8b7379c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion func.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func (p *Package) NewFuncWith(name string, sig *types.Signature) *Func {
}

fn := types.NewFunc(token.NoPos, p.Types, name, sig)
p.Types.Scope().Insert(fn)
if recv := sig.Recv(); recv != nil { // add method to this type
var t *types.Named
switch typ := recv.Type().(type) {
Expand All @@ -122,6 +121,8 @@ func (p *Package) NewFuncWith(name string, sig *types.Signature) *Func {
panic("TODO: invalid recv type")
}
t.AddMethod(fn)
} else {
p.Types.Scope().Insert(fn)
}

decl := &ast.FuncDecl{}
Expand Down

0 comments on commit 8b7379c

Please sign in to comment.