Skip to content

Commit

Permalink
Merge pull request #1482 from xushiwei/q
Browse files Browse the repository at this point in the history
typeDecl: rec.Use
  • Loading branch information
xushiwei committed Oct 21, 2023
2 parents 568cdda + 3faae92 commit 8245eb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,8 @@ func preloadFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, gopFil
if debugLoad {
log.Println("==> Preload type", name)
}
ld := getTypeLoader(parent, syms, t.Name.Pos(), name)
pos := t.Name.Pos()
ld := getTypeLoader(parent, syms, pos, name)
defs := ctx.pkg.NewTypeDefs()
if gopFile {
ld.typ = func() {
Expand All @@ -910,7 +911,7 @@ func preloadFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, gopFil
if debugLoad {
log.Println("==> Load > NewType", name)
}
decl := defs.NewType(name)
decl := defs.NewType(name, pos)
if t.Doc != nil {
defs.SetComments(t.Doc)
} else if d.Doc != nil {
Expand Down
11 changes: 10 additions & 1 deletion cl/func_type_and_var.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,16 @@ Name context:
// ---------------------------------------------------------------------------*/

func toIdentType(ctx *blockCtx, ident *ast.Ident) types.Type {
func toIdentType(ctx *blockCtx, ident *ast.Ident) (ret types.Type) {
if rec := ctx.recorder(); rec != nil {
defer func() {
if n, ok := ret.(interface {
Obj() *types.TypeName
}); ok {
rec.Use(ident, n.Obj())
}
}()
}
if ctx.tlookup != nil {
if typ := ctx.tlookup.Lookup(ident.Name); typ != nil {
return typ
Expand Down

0 comments on commit 8245eb7

Please sign in to comment.