Skip to content

Commit

Permalink
fix: resolve embedded method on pointer types
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes authored Mar 17, 2020
1 parent 953b122 commit ca68c6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions _test/struct37.go
Original file line number Diff line number Diff line change
@@ -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"))
}
2 changes: 1 addition & 1 deletion interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca68c6c

Please sign in to comment.