mirror of
https://github.com/golang/go
synced 2024-11-17 08:34:43 -07:00
[dev.typeparams] cmd/compile: fold reader checking type params logic to separate method
So making it less verbose and clearer to the reader what that check means. Change-Id: I41587aab399e63600356c5cecec64978048bed36 Reviewed-on: https://go-review.googlesource.com/c/go/+/329571 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d24c90a153
commit
3f7f72a258
@ -543,7 +543,7 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
|
|||||||
return pri.pr.objIdx(pri.idx, pri.implicits, r.explicits)
|
return pri.pr.objIdx(pri.idx, pri.implicits, r.explicits)
|
||||||
}
|
}
|
||||||
if haveLegacyImports {
|
if haveLegacyImports {
|
||||||
assert(len(r.implicits)+len(r.explicits) == 0)
|
assert(!r.hasTypeParams())
|
||||||
return typecheck.Resolve(ir.NewIdent(src.NoXPos, origSym))
|
return typecheck.Resolve(ir.NewIdent(src.NoXPos, origSym))
|
||||||
}
|
}
|
||||||
base.Fatalf("unresolved stub: %v", origSym)
|
base.Fatalf("unresolved stub: %v", origSym)
|
||||||
@ -608,7 +608,7 @@ func (pr *pkgReader) objIdx(idx int, implicits, explicits []*types.Type) ir.Node
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *reader) mangle(sym *types.Sym) *types.Sym {
|
func (r *reader) mangle(sym *types.Sym) *types.Sym {
|
||||||
if len(r.implicits)+len(r.explicits) == 0 {
|
if !r.hasTypeParams() {
|
||||||
return sym
|
return sym
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,6 +722,10 @@ func (r *reader) selector() (origPkg *types.Pkg, sym *types.Sym) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *reader) hasTypeParams() bool {
|
||||||
|
return len(r.implicits)+len(r.explicits) != 0
|
||||||
|
}
|
||||||
|
|
||||||
// @@@ Compiler extensions
|
// @@@ Compiler extensions
|
||||||
|
|
||||||
func (r *reader) funcExt(name *ir.Name) {
|
func (r *reader) funcExt(name *ir.Name) {
|
||||||
@ -739,7 +743,7 @@ func (r *reader) funcExt(name *ir.Name) {
|
|||||||
|
|
||||||
// TODO(mdempsky): Remember why I wrote this code. I think it has to
|
// TODO(mdempsky): Remember why I wrote this code. I think it has to
|
||||||
// do with how ir.VisitFuncsBottomUp works?
|
// do with how ir.VisitFuncsBottomUp works?
|
||||||
if name.Sym().Pkg == types.LocalPkg || len(r.implicits)+len(r.explicits) != 0 {
|
if name.Sym().Pkg == types.LocalPkg || r.hasTypeParams() {
|
||||||
name.Defn = fn
|
name.Defn = fn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,7 +778,7 @@ func (r *reader) typeExt(name *ir.Name) {
|
|||||||
|
|
||||||
typ := name.Type()
|
typ := name.Type()
|
||||||
|
|
||||||
if len(r.implicits)+len(r.explicits) != 0 {
|
if r.hasTypeParams() {
|
||||||
// Set "RParams" (really type arguments here, not parameters) so
|
// Set "RParams" (really type arguments here, not parameters) so
|
||||||
// this type is treated as "fully instantiated". This ensures the
|
// this type is treated as "fully instantiated". This ensures the
|
||||||
// type descriptor is written out as DUPOK and method wrappers are
|
// type descriptor is written out as DUPOK and method wrappers are
|
||||||
|
Loading…
Reference in New Issue
Block a user