Commit d8253205 authored by Robert Griesemer's avatar Robert Griesemer

go/doc: set receiver type position for embedded methods

This was a bug that didn't manifest itself before CL 7674044;
but with that CL and without this fix, the go/doc tests fail.
(The bug fixed by 7674044 and the bug fixed here cancelled
each other out w/ respect to the go/doc tests).

R=rsc
CC=golang-dev
https://golang.org/cl/7628045
parent b09d8817
......@@ -533,10 +533,13 @@ func customizeRecv(f *Func, recvTypeName string, embeddedIsPtr bool, level int)
// copy existing receiver field and set new type
newField := *f.Decl.Recv.List[0]
origPos := newField.Type.Pos()
_, origRecvIsPtr := newField.Type.(*ast.StarExpr)
var typ ast.Expr = ast.NewIdent(recvTypeName)
newIdent := &ast.Ident{NamePos: origPos, Name: recvTypeName}
var typ ast.Expr = newIdent
if !embeddedIsPtr && origRecvIsPtr {
typ = &ast.StarExpr{X: typ}
newIdent.NamePos++ // '*' is one character
typ = &ast.StarExpr{Star: origPos, X: newIdent}
}
newField.Type = typ
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment