mirror of
https://github.com/golang/go
synced 2024-11-17 08:24:43 -07:00
[dev.typeparams] cmd/compile: handle objStub earlier in reader
There's no point in reading the object dictionary for a stub declaration. Only the package that contains the full object definition will contain an object dictionary. Change-Id: I458b77d20745105bf46190ef552312bdb5ca4d06 Reviewed-on: https://go-review.googlesource.com/c/go/+/334409 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
This commit is contained in:
parent
e5faa8d84b
commit
82744bfbfc
@ -520,14 +520,22 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
|
||||
|
||||
r.typeParamBounds(sym, implicits, explicits)
|
||||
|
||||
origSym := sym
|
||||
|
||||
sym = r.mangle(sym)
|
||||
if !sym.IsBlank() && sym.Def != nil {
|
||||
return sym.Def.(ir.Node)
|
||||
}
|
||||
|
||||
tag := codeObj(r.code(syncCodeObj))
|
||||
if tag == objStub {
|
||||
assert(!sym.IsBlank())
|
||||
switch sym.Pkg {
|
||||
case types.BuiltinPkg, ir.Pkgs.Unsafe:
|
||||
return sym.Def.(ir.Node)
|
||||
}
|
||||
if pri, ok := objReader[sym]; ok {
|
||||
return pri.pr.objIdx(pri.idx, nil, explicits)
|
||||
}
|
||||
if haveLegacyImports {
|
||||
assert(!r.hasTypeParams())
|
||||
return typecheck.Resolve(ir.NewIdent(src.NoXPos, sym))
|
||||
}
|
||||
base.Fatalf("unresolved stub: %v", sym)
|
||||
}
|
||||
|
||||
{
|
||||
rdict := pr.newReader(relocObjDict, idx, syncObject1)
|
||||
@ -538,6 +546,11 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
|
||||
}
|
||||
}
|
||||
|
||||
sym = r.mangle(sym)
|
||||
if !sym.IsBlank() && sym.Def != nil {
|
||||
return sym.Def.(*ir.Name)
|
||||
}
|
||||
|
||||
do := func(op ir.Op, hasTParams bool) *ir.Name {
|
||||
pos := r.pos()
|
||||
if hasTParams {
|
||||
@ -560,17 +573,6 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
|
||||
default:
|
||||
panic("unexpected object")
|
||||
|
||||
case objStub:
|
||||
if pri, ok := objReader[origSym]; ok {
|
||||
return pri.pr.objIdx(pri.idx, nil, explicits)
|
||||
}
|
||||
if haveLegacyImports {
|
||||
assert(!r.hasTypeParams())
|
||||
return typecheck.Resolve(ir.NewIdent(src.NoXPos, origSym))
|
||||
}
|
||||
base.Fatalf("unresolved stub: %v", origSym)
|
||||
panic("unreachable")
|
||||
|
||||
case objAlias:
|
||||
name := do(ir.OTYPE, false)
|
||||
r.setType(name, r.typ())
|
||||
|
Loading…
Reference in New Issue
Block a user