]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: set receiver type position for embedded methods
authorRobert Griesemer <gri@golang.org>
Tue, 12 Mar 2013 20:06:55 +0000 (13:06 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 12 Mar 2013 20:06:55 +0000 (13:06 -0700)
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

index dd6a57299e62cb073f04f80187b78fb493edd164..a1b7b84be92f451af173bcf735d42f5d8323d393 100644 (file)
@@ -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