Updates #19683.
Change-Id: I64b3b93a3ab14518a5376e1270bdd2a94bdd67ef
Reviewed-on: https://go-review.googlesource.com/59611
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
func (p *importer) obj(tag int) {
switch tag {
case constTag:
- p.pos()
+ pos := p.pos()
sym := p.qualifiedName()
typ := p.typ()
val := p.value(typ)
- importconst(p.imp, sym, idealType(typ), nodlit(val))
+ importconst(p.imp, sym, idealType(typ), npos(pos, nodlit(val)))
case aliasTag:
- p.pos()
+ pos := p.pos()
sym := p.qualifiedName()
typ := p.typ()
- importalias(p.imp, sym, typ)
+ importalias(pos, p.imp, sym, typ)
case typeTag:
p.typ()
case varTag:
- p.pos()
+ pos := p.pos()
sym := p.qualifiedName()
typ := p.typ()
- importvar(p.imp, sym, typ)
+ importvar(pos, p.imp, sym, typ)
case funcTag:
- p.pos()
+ pos := p.pos()
sym := p.qualifiedName()
params := p.paramList()
result := p.paramList()
break
}
- n := newfuncname(sym)
+ n := newfuncnamel(pos, sym)
n.Type = sig
declare(n, PFUNC)
p.funcList = append(p.funcList, n)
var t *types.Type
switch i {
case namedTag:
- p.pos()
+ pos := p.pos()
tsym := p.qualifiedName()
- t = pkgtype(p.imp, tsym)
+ t = pkgtype(pos, p.imp, tsym)
p.typList = append(p.typList, t)
dup := !t.IsKind(types.TFORW) // type already imported
// read associated methods
for i := p.int(); i > 0; i-- {
- p.pos()
+ mpos := p.pos()
sym := p.fieldSym()
// during import unexported method names should be in the type's package
continue
}
- n := newfuncname(methodname(sym, recv[0].Type))
+ n := newfuncnamel(mpos, methodname(sym, recv[0].Type))
n.Type = mt
checkwidth(n.Type)
p.funcList = append(p.funcList, n)
}
func (p *importer) field() *types.Field {
- p.pos()
+ pos := p.pos()
sym, alias := p.fieldName()
typ := p.typ()
note := p.string()
}
f.Sym = sym
- f.Nname = asTypesNode(newname(sym))
+ f.Nname = asTypesNode(newnamel(pos, sym))
f.Type = typ
f.Note = note
}
func (p *importer) method() *types.Field {
- p.pos()
+ pos := p.pos()
sym := p.methodName()
params := p.paramList()
result := p.paramList()
f := types.NewField()
f.Sym = sym
- f.Nname = asTypesNode(newname(sym))
+ f.Nname = asTypesNode(newnamel(pos, sym))
f.Type = functypefield(fakeRecvField(), params, result)
return f
}
// newfuncname generates a new name node for a function or method.
// TODO(rsc): Use an ODCLFUNC node instead. See comment in CL 7360.
func newfuncname(s *types.Sym) *Node {
- n := newname(s)
+ return newfuncnamel(lineno, s)
+}
+
+// newfuncnamel generates a new name node for a function or method.
+// TODO(rsc): Use an ODCLFUNC node instead. See comment in CL 7360.
+func newfuncnamel(pos src.XPos, s *types.Sym) *Node {
+ n := newnamel(pos, s)
n.Func = new(Func)
n.Func.SetIsHiddenClosure(Curfn != nil)
return n
}
func typenod(t *types.Type) *Node {
+ return typenodl(lineno, t)
+}
+
+func typenodl(pos src.XPos, t *types.Type) *Node {
// if we copied another type with *t = *u
// then t->nod might be out of date, so
// check t->nod->type too
if asNode(t.Nod) == nil || asNode(t.Nod).Type != t {
- t.Nod = asTypesNode(nod(OTYPE, nil, nil))
+ t.Nod = asTypesNode(nodl(pos, OTYPE, nil, nil))
asNode(t.Nod).Type = t
asNode(t.Nod).Sym = t.Sym
}
"bytes"
"cmd/compile/internal/types"
"cmd/internal/bio"
+ "cmd/internal/src"
"fmt"
"unicode"
"unicode/utf8"
// pkgtype returns the named type declared by symbol s.
// If no such type has been declared yet, a forward declaration is returned.
// pkg is the package being imported
-func pkgtype(pkg *types.Pkg, s *types.Sym) *types.Type {
+func pkgtype(pos src.XPos, pkg *types.Pkg, s *types.Sym) *types.Type {
importsym(pkg, s, OTYPE)
if asNode(s.Def) == nil || asNode(s.Def).Op != OTYPE {
t := types.New(TFORW)
t.Sym = s
- s.Def = asTypesNode(typenod(t))
+ s.Def = asTypesNode(typenodl(pos, t))
asNode(s.Def).Name = new(Name)
}
// importvar declares symbol s as an imported variable with type t.
// pkg is the package being imported
-func importvar(pkg *types.Pkg, s *types.Sym, t *types.Type) {
+func importvar(pos src.XPos, pkg *types.Pkg, s *types.Sym, t *types.Type) {
importsym(pkg, s, ONAME)
if asNode(s.Def) != nil && asNode(s.Def).Op == ONAME {
if eqtype(t, asNode(s.Def).Type) {
yyerror("inconsistent definition for var %v during import\n\t%v (in %q)\n\t%v (in %q)", s, asNode(s.Def).Type, s.Importdef.Path, t, pkg.Path)
}
- n := newname(s)
+ n := newnamel(pos, s)
s.Importdef = pkg
n.Type = t
declare(n, PEXTERN)
// importalias declares symbol s as an imported type alias with type t.
// pkg is the package being imported
-func importalias(pkg *types.Pkg, s *types.Sym, t *types.Type) {
+func importalias(pos src.XPos, pkg *types.Pkg, s *types.Sym, t *types.Type) {
importsym(pkg, s, OTYPE)
if asNode(s.Def) != nil && asNode(s.Def).Op == OTYPE {
if eqtype(t, asNode(s.Def).Type) {
yyerror("inconsistent definition for type alias %v during import\n\t%v (in %q)\n\t%v (in %q)", s, asNode(s.Def).Type, s.Importdef.Path, t, pkg.Path)
}
- n := newname(s)
+ n := newnamel(pos, s)
n.Op = OTYPE
s.Importdef = pkg
n.Type = t
n.Type = typ
declare(n, PFUNC)
case varTag:
- importvar(Runtimepkg, sym, typ)
+ importvar(lineno, Runtimepkg, sym, typ)
default:
Fatalf("unhandled declaration tag %v", d.tag)
}