From d825320550b87158286ec772baddab81d07079e0 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 12 Mar 2013 13:06:55 -0700 Subject: [PATCH] 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 --- src/pkg/go/doc/reader.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pkg/go/doc/reader.go b/src/pkg/go/doc/reader.go index dd6a57299e..a1b7b84be9 100644 --- a/src/pkg/go/doc/reader.go +++ b/src/pkg/go/doc/reader.go @@ -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 -- 2.50.0