Commit 8a2a9993 authored by Robert Griesemer's avatar Robert Griesemer

go/types: document that selectors are not recorded in Info.Types

Fixes #11944.

Change-Id: I424ba93725f22fd599e052eb182f9ba2fca8e8bd
Reviewed-on: https://go-review.googlesource.com/32881Reviewed-by: default avatarAlan Donovan <adonovan@google.com>
parent 248a5944
...@@ -135,7 +135,8 @@ type Config struct { ...@@ -135,7 +135,8 @@ type Config struct {
// be incomplete. // be incomplete.
type Info struct { type Info struct {
// Types maps expressions to their types, and for constant // Types maps expressions to their types, and for constant
// expressions, their values. Invalid expressions are omitted. // expressions, also their values. Invalid expressions are
// omitted.
// //
// For (possibly parenthesized) identifiers denoting built-in // For (possibly parenthesized) identifiers denoting built-in
// functions, the recorded signatures are call-site specific: // functions, the recorded signatures are call-site specific:
...@@ -143,9 +144,13 @@ type Info struct { ...@@ -143,9 +144,13 @@ type Info struct {
// an argument-specific signature. Otherwise, the recorded type // an argument-specific signature. Otherwise, the recorded type
// is invalid. // is invalid.
// //
// Identifiers on the lhs of declarations (i.e., the identifiers // The Types map does not record the type of every identifier,
// which are being declared) are collected in the Defs map. // only those that appear where an arbitrary expression is
// Identifiers denoting packages are collected in the Uses maps. // permitted. For instance, the identifier f in a selector
// expression x.f is found only in the Selections map, the
// identifier z in a variable declaration 'var z int' is found
// only in the Defs map, and identifiers denoting packages in
// qualified identifiers are collected in the Uses map.
Types map[ast.Expr]TypeAndValue Types map[ast.Expr]TypeAndValue
// Defs maps identifiers to the objects they define (including // Defs maps identifiers to the objects they define (including
......
...@@ -345,7 +345,6 @@ func (check *Checker) recordImplicit(node ast.Node, obj Object) { ...@@ -345,7 +345,6 @@ func (check *Checker) recordImplicit(node ast.Node, obj Object) {
func (check *Checker) recordSelection(x *ast.SelectorExpr, kind SelectionKind, recv Type, obj Object, index []int, indirect bool) { func (check *Checker) recordSelection(x *ast.SelectorExpr, kind SelectionKind, recv Type, obj Object, index []int, indirect bool) {
assert(obj != nil && (recv == nil || len(index) > 0)) assert(obj != nil && (recv == nil || len(index) > 0))
check.recordUse(x.Sel, obj) check.recordUse(x.Sel, obj)
// TODO(gri) Should we also call recordTypeAndValue?
if m := check.Selections; m != nil { if m := check.Selections; m != nil {
m[x] = &Selection{kind, recv, obj, index, indirect} m[x] = &Selection{kind, recv, obj, index, indirect}
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment