aboutsummaryrefslogtreecommitdiff
path: root/src/go/internal/gcimporter/iimport.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/go/internal/gcimporter/iimport.go')
-rw-r--r--src/go/internal/gcimporter/iimport.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/go/internal/gcimporter/iimport.go b/src/go/internal/gcimporter/iimport.go
index 1fe139da17..f570aab2bf 100644
--- a/src/go/internal/gcimporter/iimport.go
+++ b/src/go/internal/gcimporter/iimport.go
@@ -72,7 +72,7 @@ const (
structType
interfaceType
typeParamType
- instType
+ instanceType
unionType
)
@@ -309,16 +309,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)
@@ -339,7 +340,7 @@ func (r *importReader) obj(name string) {
for i := range rparams {
rparams[i], _ = targs.At(i).(*types.TypeParam)
}
- msig.SetRParams(rparams)
+ msig.SetRecvTypeParams(rparams)
}
named.AddMethod(types.NewFunc(mpos, r.currPkg, mname, msig))
@@ -637,7 +638,7 @@ func (r *importReader) doType(base *types.Named) types.Type {
r.p.doDecl(pkg, name)
return r.p.tparamIndex[id]
- case instType:
+ case instanceType:
if r.p.exportVersion < iexportVersionGenerics {
errorf("unexpected instantiation type")
}
@@ -652,7 +653,7 @@ func (r *importReader) doType(base *types.Named) types.Type {
baseType := r.typ()
// The imported instantiated type doesn't include any methods, so
// we must always use the methods of the base (orig) type.
- // TODO provide a non-nil *Checker
+ // TODO provide a non-nil *Environment
t, _ := types.Instantiate(nil, baseType, targs, false)
return t