compiler: properly inline methods, use receiver
Notice that this doesn't differentiate between (*T) and (T) receivers always treating them as is. But we have the same problem with arguments now and the number of inlined calls is limited, usually we want this behavior.
This commit is contained in:
parent
6014dd720f
commit
b57dd2cad6
3 changed files with 38 additions and 0 deletions
|
@ -55,6 +55,15 @@ func (c *codegen) inlineCall(f *funcScope, n *ast.CallExpr) {
|
|||
copy(newScope, c.scope.vars.locals)
|
||||
defer c.scope.vars.dropScope()
|
||||
|
||||
if f.decl.Recv != nil {
|
||||
c.scope.vars.locals = newScope
|
||||
name := f.decl.Recv.List[0].Names[0].Name
|
||||
c.scope.vars.addAlias(name, -1, unspecifiedVarIndex, &varContext{
|
||||
importMap: c.importMap,
|
||||
expr: f.selector,
|
||||
scope: oldScope,
|
||||
})
|
||||
}
|
||||
hasVarArgs := !n.Ellipsis.IsValid()
|
||||
needPack := sig.Variadic() && hasVarArgs
|
||||
for i := range n.Args {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue