aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/noder.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-05-26 19:52:31 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-05-27 22:13:38 +0000
commitde5d1aca5e61e49e0704213961c68bcf14e288b8 (patch)
tree75dc1b2d831442b26bc6e3e28a3274a12b82d7af /src/cmd/compile/internal/noder/noder.go
parentc2c1b53b39fd54b915b2a4bbae36d1c9793fac8a (diff)
downloadgo-de5d1aca5e61e49e0704213961c68bcf14e288b8.tar.gz
go-de5d1aca5e61e49e0704213961c68bcf14e288b8.zip
[dev.typeparams] cmd/compile: tweaks to match types2
This CL makes a handful of changes to either bring existing compiler output consistent with what types2 produces or to make it easier to reproduce with types2: 1. The position for embedded fields is corrected to the position of the syntax.Field, rather than the syntax.Type. 2. Methods and embedded types are sorted in export data the same way that types2 sorts them. 3. Don't write out position information for OLITERALs that don't have their own position (i.e., references to named constants). Change-Id: Ic3979215ae9ef280cfbba7b44c236e03fc12a2ef Reviewed-on: https://go-review.googlesource.com/c/go/+/323209 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Trust: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder/noder.go')
-rw-r--r--src/cmd/compile/internal/noder/noder.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/noder/noder.go b/src/cmd/compile/internal/noder/noder.go
index 06c3b00601..44385f34fd 100644
--- a/src/cmd/compile/internal/noder/noder.go
+++ b/src/cmd/compile/internal/noder/noder.go
@@ -986,6 +986,8 @@ func (p *noder) packname(expr syntax.Expr) *types.Sym {
}
func (p *noder) embedded(typ syntax.Expr) *ir.Field {
+ pos := p.pos(syntax.StartPos(typ))
+
op, isStar := typ.(*syntax.Operation)
if isStar {
if op.Op != syntax.Mul || op.Y != nil {
@@ -995,11 +997,11 @@ func (p *noder) embedded(typ syntax.Expr) *ir.Field {
}
sym := p.packname(typ)
- n := ir.NewField(p.pos(typ), typecheck.Lookup(sym.Name), importName(sym).(ir.Ntype), nil)
+ n := ir.NewField(pos, typecheck.Lookup(sym.Name), importName(sym).(ir.Ntype), nil)
n.Embedded = true
if isStar {
- n.Ntype = ir.NewStarExpr(p.pos(op), n.Ntype)
+ n.Ntype = ir.NewStarExpr(pos, n.Ntype)
}
return n
}