mirror of
https://github.com/golang/go
synced 2024-11-17 11:54:54 -07:00
go/internal/gcimporter: prevent importReader reading type parameter twice
This is port of CL 349009 to go/internal/gcimporter. Updates #48280 Change-Id: I7d40d8b67333538ca58fe012535d54e891d0ed16 Reviewed-on: https://go-review.googlesource.com/c/go/+/349010 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: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
b8c802b116
commit
2953cd0083
@ -284,6 +284,8 @@ type importReader struct {
|
||||
prevColumn int64
|
||||
}
|
||||
|
||||
// obj reads import declaration for an object. It may not read
|
||||
// the entire declaration, e.g, for recursive type.
|
||||
func (r *importReader) obj(name string) {
|
||||
tag := r.byte()
|
||||
pos := r.pos()
|
||||
@ -309,16 +311,17 @@ func (r *importReader) obj(name string) {
|
||||
r.declare(types.NewFunc(pos, r.currPkg, name, sig))
|
||||
|
||||
case 'T', 'U':
|
||||
var tparams []*types.TypeParam
|
||||
if tag == 'U' {
|
||||
tparams = r.tparamList()
|
||||
}
|
||||
// Types can be recursive. We need to setup a stub
|
||||
// declaration before recursing.
|
||||
obj := types.NewTypeName(pos, r.currPkg, name, nil)
|
||||
named := types.NewNamed(obj, nil, nil)
|
||||
named.SetTypeParams(tparams)
|
||||
// Declare obj before calling r.tparamList, so the new type name is recognized
|
||||
// if used in the constraint of one of its own typeparams (see #48280).
|
||||
r.declare(obj)
|
||||
if tag == 'U' {
|
||||
tparams := r.tparamList()
|
||||
named.SetTypeParams(tparams)
|
||||
}
|
||||
|
||||
underlying := r.p.typAt(r.uint64(), named).Underlying()
|
||||
named.SetUnderlying(underlying)
|
||||
|
Loading…
Reference in New Issue
Block a user