mirror of
https://github.com/golang/go
synced 2024-11-23 00:10:07 -07:00
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
This commit is contained in:
parent
b09d881799
commit
d825320550
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user