mirror of
https://github.com/golang/go
synced 2024-11-20 07:04:40 -07:00
- handle type forward declarations correctly
R=r DELTA=8 (6 added, 0 deleted, 2 changed) OCL=31537 CL=31537
This commit is contained in:
parent
efb918b7db
commit
32cd887574
@ -77,8 +77,12 @@ func (doc *DocReader) lookupTypeDoc(typ ast.Expr) *typeDoc {
|
|||||||
func (doc *DocReader) addType(decl *ast.GenDecl) {
|
func (doc *DocReader) addType(decl *ast.GenDecl) {
|
||||||
typ := decl.Specs[0].(*ast.TypeSpec);
|
typ := decl.Specs[0].(*ast.TypeSpec);
|
||||||
name := typ.Name.Value;
|
name := typ.Name.Value;
|
||||||
tdoc := &typeDoc{decl, make(map[string] *ast.FuncDecl), make(map[string] *ast.FuncDecl)};
|
if _, found := doc.types[name]; !found {
|
||||||
doc.types[name] = tdoc;
|
tdoc := &typeDoc{decl, make(map[string] *ast.FuncDecl), make(map[string] *ast.FuncDecl)};
|
||||||
|
doc.types[name] = tdoc;
|
||||||
|
}
|
||||||
|
// If the type was found it may have been added as a forward
|
||||||
|
// declaration before, or this is a forward-declaration.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,6 +94,8 @@ func (doc *DocReader) addFunc(fun *ast.FuncDecl) {
|
|||||||
if fun.Recv != nil {
|
if fun.Recv != nil {
|
||||||
// method
|
// method
|
||||||
// (all receiver types must be declared before they are used)
|
// (all receiver types must be declared before they are used)
|
||||||
|
// TODO(gri) Reconsider this logic if no forward-declarations
|
||||||
|
// are required anymore.
|
||||||
typ = doc.lookupTypeDoc(fun.Recv.Type);
|
typ = doc.lookupTypeDoc(fun.Recv.Type);
|
||||||
if typ != nil {
|
if typ != nil {
|
||||||
// type found (i.e., exported)
|
// type found (i.e., exported)
|
||||||
|
Loading…
Reference in New Issue
Block a user