diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index f1d86748a..693bd7efd 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -914,15 +914,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { return nil } case *ast.SelectorExpr: - // If this is a method call we need to walk the AST to load the struct locally. - // Otherwise, this is a function call from an imported package and we can call it - // directly. name, isMethod := c.getFuncNameFromSelector(fun) - if isMethod { - ast.Walk(c, fun.X) - // Don't forget to add 1 extra argument when its a method. - numArgs++ - } f, ok = c.funcs[name] if ok { @@ -938,6 +930,14 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor { c.emitExplicitConvert(c.typeOf(n.Args[0]), typ) return nil } + if isMethod { + // If this is a method call we need to walk the AST to load the struct locally. + // Otherwise, this is a function call from an imported package and we can call it + // directly. + ast.Walk(c, fun.X) + // Don't forget to add 1 extra argument when it's a method. + numArgs++ + } case *ast.ArrayType: // For now we will assume that there are only byte slice conversions. // E.g. []byte("foobar") or []byte(scriptHash).