Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeDecl: rec.Use #1482

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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