mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[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>
This commit is contained in:
parent
c2c1b53b39
commit
de5d1aca5e
4 changed files with 38 additions and 13 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue