]> Cypherpunks repositories - gostls13.git/commit
go/types: add CheckExpr function to type-check an expression
authorAlan Donovan <adonovan@google.com>
Thu, 25 Oct 2018 20:44:44 +0000 (16:44 -0400)
committerAlan Donovan <adonovan@google.com>
Wed, 8 May 2019 18:24:30 +0000 (18:24 +0000)
commit19966e9b533a85039458eabf08228e0b85f3bf4e
treea60b370ee8082663082db45c99e63077cf2bdd98
parent5a2da5624a9403a61cdd8df529e2b71129ef7898
go/types: add CheckExpr function to type-check an expression

In IDE-like applications (and also in tests), there is often a need to
type-check an expression as if it appeared at a particular position in
the source code of an already typed-checked package.

Eval was added to address this need, but did so only partially,
stopping short of exposing a type-annotated expression tree. This
makes it impossible to resolve an expression such as new(T).x and
discover what Object x refers to.  CheckExpr exposes that generality.
Eval is now implemented in terms of CheckExpr.

This change includes a test that demonstrates the object resolution
functionality just described.

Historical context:
- https://go-review.googlesource.com/c/tools/+/10800
- https://codereview.appspot.com/10748044/

Change-Id: I715ba934b9fc0c9ceb61270e20c5f91f4eff20c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/144677
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/eval.go
src/go/types/eval_test.go