]> Cypherpunks repositories - gostls13.git/commit
go/types: add Checker.walkDecl to simplify checking declarations
authorRob Findley <rfindley@google.com>
Mon, 21 Sep 2020 12:47:34 +0000 (08:47 -0400)
committerRobert Findley <rfindley@google.com>
Fri, 2 Oct 2020 15:40:59 +0000 (15:40 +0000)
commit79dbdf2a4c2ad93d3de493956f8bbca1465ba932
tree99d85645f1c7e1642e2bbfee4e5cf499752ee988
parent44a15a7262b14d517fefab5b7c13ca97ab099a30
go/types: add Checker.walkDecl to simplify checking declarations

Handling ast.GenDecls while typechecking is repetitive, and a source of
diffs compared to typechecking using the cmd/compile/internal/syntax
package, which unpacks declaration groups into individual declarations.

Refactor to extract the logic for walking declarations.  This introduces
a new AST abstraction: types.decl, which comes at some minor performance
cost. However, if we are to fully abstract the AST we will be paying
this cost anyway, and benchmarking suggests that the cost is negligible.

Change-Id: If73c30c3d08053ccf7bf21ef886f0452fdbf142e
Reviewed-on: https://go-review.googlesource.com/c/go/+/256298
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
src/go/types/decl.go
src/go/types/resolver.go