aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/importer/iimport.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/importer/iimport.go')
-rw-r--r--src/cmd/compile/internal/importer/iimport.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cmd/compile/internal/importer/iimport.go b/src/cmd/compile/internal/importer/iimport.go
index 38cb8db2355..a92720d52e2 100644
--- a/src/cmd/compile/internal/importer/iimport.go
+++ b/src/cmd/compile/internal/importer/iimport.go
@@ -72,7 +72,7 @@ const (
structType
interfaceType
typeParamType
- instType
+ instanceType
unionType
)
@@ -314,21 +314,21 @@ func (r *importReader) obj(name string) {
tparams = r.tparamList()
}
sig := r.signature(nil)
- sig.SetTParams(tparams)
+ sig.SetTypeParams(tparams)
r.declare(types2.NewFunc(pos, r.currPkg, name, sig))
case 'T', 'U':
- var tparams []*types2.TypeParam
- if tag == 'U' {
- tparams = r.tparamList()
- }
-
// Types can be recursive. We need to setup a stub
// declaration before recursing.
obj := types2.NewTypeName(pos, r.currPkg, name, nil)
named := types2.NewNamed(obj, nil, nil)
- named.SetTParams(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)
@@ -343,13 +343,13 @@ func (r *importReader) obj(name string) {
// If the receiver has any targs, set those as the
// rparams of the method (since those are the
// typeparams being used in the method sig/body).
- targs := baseType(msig.Recv().Type()).TArgs()
+ targs := baseType(msig.Recv().Type()).TypeArgs()
if targs.Len() > 0 {
rparams := make([]*types2.TypeParam, targs.Len())
for i := range rparams {
rparams[i] = types2.AsTypeParam(targs.At(i))
}
- msig.SetRParams(rparams)
+ msig.SetRecvTypeParams(rparams)
}
named.AddMethod(types2.NewFunc(mpos, r.currPkg, mname, msig))
@@ -365,7 +365,7 @@ func (r *importReader) obj(name string) {
}
name0, sub := parseSubscript(name)
tn := types2.NewTypeName(pos, r.currPkg, name0, nil)
- t := (*types2.Checker)(nil).NewTypeParam(tn, nil)
+ t := types2.NewTypeParam(tn, nil)
if sub == 0 {
errorf("missing subscript")
}
@@ -646,7 +646,7 @@ func (r *importReader) doType(base *types2.Named) types2.Type {
r.p.doDecl(pkg, name)
return r.p.tparamIndex[id]
- case instType:
+ case instanceType:
if r.p.exportVersion < iexportVersionGenerics {
errorf("unexpected instantiation type")
}
@@ -661,7 +661,7 @@ func (r *importReader) doType(base *types2.Named) types2.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, _ := types2.Instantiate(nil, baseType, targs, false)
return t