From ca68c6cd95839859308ac819cec0d2032799318f Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Tue, 17 Mar 2020 18:14:04 +0100 Subject: [PATCH] fix: resolve embedded method on pointer types --- _test/struct37.go | 17 +++++++++++++++++ interp/cfg.go | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 _test/struct37.go diff --git a/_test/struct37.go b/_test/struct37.go new file mode 100644 index 000000000..1ac7c9139 --- /dev/null +++ b/_test/struct37.go @@ -0,0 +1,17 @@ +package main + +import ( + "net/http" + "strings" +) + +type MyHttpClient struct { + *http.Client +} + +func main() { + c := new(MyHttpClient) + c.Client = new(http.Client) + _, err := c.Get("url") + println(strings.Contains(err.Error(), "unsupported protocol scheme")) +} diff --git a/interp/cfg.go b/interp/cfg.go index d854e3d9d..6bf6233dc 100644 --- a/interp/cfg.go +++ b/interp/cfg.go @@ -1214,7 +1214,7 @@ func (interp *Interpreter) cfg(root *node, pkgID string) ([]*node, error) { n.recv = &receiver{node: n.child[0], index: lind} } } else if m, lind, isPtr, ok := n.typ.lookupBinMethod(n.child[1].ident); ok { - if isPtr { + if isPtr && n.typ.fieldSeq(lind).cat != ptrT { n.gen = getIndexSeqPtrMethod } else { n.gen = getIndexSeqMethod