Skip to content

Commit

Permalink
typesutil.Check: ident/selectorExpr rec.Type
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Oct 22, 2023
1 parent 94efdcd commit 2f66dc5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cl/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ find:
}
if rec := ctx.recorder(); rec != nil {
rec.Use(ident, o)
e := ctx.cb.Get(-1)
tv := types.TypeAndValue{Type: e.Type, Value: e.CVal}
if !fvalue {
tv.Type = o.Type()
}
rec.Type(ident, tv)
}
return
}
Expand Down Expand Up @@ -368,6 +374,10 @@ func compileSelectorExpr(ctx *blockCtx, v *ast.SelectorExpr, flags int) {
}
default:
compileExpr(ctx, v.X)
if rec := ctx.recorder(); rec != nil {
e := ctx.cb.Get(-1)
rec.Type(v.X, types.TypeAndValue{Type: e.Type, Value: e.CVal})
}
}
if err := compileMember(ctx, v, v.Sel.Name, flags); err != nil {
panic(err)
Expand Down
3 changes: 3 additions & 0 deletions x/typesutil/gopinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ type gopRecorder struct {
// only in the Defs map, and identifiers denoting packages in
// qualified identifiers are collected in the Uses map.
func (info gopRecorder) Type(e ast.Expr, tv types.TypeAndValue) {
if debugVerbose {
log.Println("==> Type:", e, tv.Type)
}
info.Types[e] = tv
}

Expand Down

0 comments on commit 2f66dc5

Please sign in to comment.