diff options
author | Robert Griesemer <gri@golang.org> | 2020-12-10 21:16:02 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2020-12-14 21:41:25 +0000 |
commit | 3a912f279fb6e3b6942a3a6c2449288a33351b69 (patch) | |
tree | e8098ab2709d66c9d35ecea60b403490301c0b47 /src/cmd/compile/internal/types2/stmt.go | |
parent | 8ec9e890008e681dcebdae50379b785eb6f160bb (diff) | |
download | go-3a912f279fb6e3b6942a3a6c2449288a33351b69.tar.gz go-3a912f279fb6e3b6942a3a6c2449288a33351b69.zip |
[dev.typeparams] cmd/compile/internal/syntax: export NewName and use it
Most syntax.Nodes are allocated in one place and there didn't
seem a need to provide factory methods - so as a matter of
API design, all nodes are "naked", without any constructors.
However, Name nodes are frequently used/replaced and also
are created as helper nodes in clients (types2). Make an
exception and export NewName.
Change-Id: I4b5c499d65bba74592dea68b0936c118b3edaca7
Reviewed-on: https://go-review.googlesource.com/c/go/+/277572
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/stmt.go')
-rw-r--r-- | src/cmd/compile/internal/types2/stmt.go | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index f1317fa0a3..477bc58bd0 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -596,14 +596,6 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) { } } -func newName(pos syntax.Pos, value string) *syntax.Name { - n := new(syntax.Name) - // TODO(gri) why does this not work? - //n.pos = pos - n.Value = value - return n -} - func (check *Checker) switchStmt(inner stmtContext, s *syntax.SwitchStmt) { // init statement already handled @@ -624,7 +616,7 @@ func (check *Checker) switchStmt(inner stmtContext, s *syntax.SwitchStmt) { if len(s.Body) > 0 { pos = s.Body[0].Pos() } - x.expr = newName(pos, "true") + x.expr = syntax.NewName(pos, "true") } check.multipleSwitchDefaults(s.Body) |