]> Cypherpunks repositories - gostls13.git/commit
[dev.typeparams] cmd/compile/internal/syntax: go/ast-style walk API
authorMatthew Dempsky <mdempsky@google.com>
Wed, 23 Jun 2021 19:08:42 +0000 (12:08 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 23 Jun 2021 22:23:16 +0000 (22:23 +0000)
commit8165256bc2e3298b0d612471d7d2e6c005b984de
tree18882bef09768ca852175c55bb9edfbc73b3e269
parenta72a499c24cfcfce2a16ac7c228c2c914c4f36c4
[dev.typeparams] cmd/compile/internal/syntax: go/ast-style walk API

This CL adds go/ast's Visitor, Walk, and Inspect functions to package
syntax. Having functions with the same API and semantics as their
go/ast counterparts reduces the mental load of context switching
between go/ast and syntax.

It also renames the existing Walk function into Crawl, and marks it as
a deprecated wrapper around Inspect. (I named it "Crawl" because it's
less functional than "Walk"... get it??)

There aren't that many callers to Crawl, so we can probably remove it
in the future. But it doesn't seem pressing, and I'm more concerned
about the risk of forgetting to invert a bool condition somewhere.

Change-Id: Ib2fb275873a1d1a730249c9cb584864cb6ec370e
Reviewed-on: https://go-review.googlesource.com/c/go/+/330429
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/irgen.go
src/cmd/compile/internal/noder/quirks.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/syntax/walk.go
src/cmd/compile/internal/types2/errorcalls_test.go
src/cmd/compile/internal/types2/issues_test.go
src/cmd/compile/internal/types2/resolver_test.go