]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types, types2: rename RParams -> RecvTypeParams
authorRobert Findley <rfindley@google.com>
Thu, 9 Sep 2021 13:26:40 +0000 (09:26 -0400)
committerRobert Findley <rfindley@google.com>
Thu, 9 Sep 2021 17:02:45 +0000 (17:02 +0000)
To be consistent with CL 348376, spell out 'RecvTypeParams' in go/types
and types2 API.

Updates #47916

Change-Id: If8b3fd4274ccb944bd0ff04d7007e94e5fba61c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/348810
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/importer/iimport.go
src/cmd/compile/internal/noder/reader2.go
src/cmd/compile/internal/noder/types.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/signature.go
src/go/internal/gcimporter/iimport.go
src/go/types/call.go
src/go/types/lookup.go
src/go/types/signature.go

index 8fdd8797054153588180e75c1a871c308cb9c1de..b61b1e97fb7cf3f028fbb231c3957afaf66d5ce9 100644 (file)
@@ -349,7 +349,7 @@ func (r *importReader) obj(name string) {
                                        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))
index 0cfde24b58e0fa7f4a6d2f744ad2c85576b5449f..dcd9a65f404a39f21be6470e5b4e42be9bccf85f 100644 (file)
@@ -492,7 +492,7 @@ func (r *reader2) method() *types2.Func {
 
        rparams := r.typeParamNames()
        sig := r.signature(r.param())
-       sig.SetRParams(rparams)
+       sig.SetRecvTypeParams(rparams)
 
        _ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go.
        return types2.NewFunc(pos, pkg, name, sig)
index b0b9c1592a7d8f846cb7b6c882e3ead882957b66..03fb96c48b56bbbae9b314c4d2c2a9535b68bd79 100644 (file)
@@ -309,7 +309,7 @@ func (g *irgen) fillinMethods(typ *types2.Named, ntyp *types.Type) {
                                meth2 = newsym.Def.(*ir.Name)
                        } else {
                                meth2 = ir.NewNameAt(meth.Pos(), newsym)
-                               rparams := types2.AsSignature(m.Type()).RParams()
+                               rparams := types2.AsSignature(m.Type()).RecvTypeParams()
                                tparams := make([]*types.Type, rparams.Len())
                                for i := range tparams {
                                        tparams[i] = g.typ1(rparams.At(i))
index e1413da1d85716e64380831522847a34003155e9..6a66bea239b02714012cefcf612b1cb9ea973d65 100644 (file)
@@ -648,7 +648,7 @@ func (w *writer) method(wext *writer, meth *types2.Func) {
        w.sync(syncMethod)
        w.pos(meth)
        w.selector(meth)
-       w.typeParamNames(sig.RParams())
+       w.typeParamNames(sig.RecvTypeParams())
        w.param(sig.Recv())
        w.signature(sig)
 
@@ -1665,7 +1665,7 @@ func (w *writer) pkgDecl(decl syntax.Decl) {
                obj := w.p.info.Defs[decl.Name].(*types2.Func)
                sig := obj.Type().(*types2.Signature)
 
-               if sig.RParams() != nil || sig.TypeParams() != nil {
+               if sig.RecvTypeParams() != nil || sig.TypeParams() != nil {
                        break // skip generic functions
                }
 
@@ -1851,7 +1851,7 @@ func objTypeParams(obj types2.Object) *types2.TypeParamList {
        case *types2.Func:
                sig := obj.Type().(*types2.Signature)
                if sig.Recv() != nil {
-                       return sig.RParams()
+                       return sig.RecvTypeParams()
                }
                return sig.TypeParams()
        case *types2.TypeName:
index f6aaa461b9632785681b1d46fa09de3d4622406c..ba3bb475a31a3a8cb1d6be6ffe9e87af1ab9f357 100644 (file)
@@ -535,7 +535,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr) {
                // the signature accordingly.
                // TODO(gri) factor this code out
                sig := m.typ.(*Signature)
-               if sig.RParams().Len() > 0 {
+               if sig.RecvTypeParams().Len() > 0 {
                        // For inference to work, we must use the receiver type
                        // matching the receiver in the actual method declaration.
                        // If the method is embedded, the matching receiver is the
@@ -564,7 +564,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr) {
                        // the receiver type arguments here, the receiver must be be otherwise invalid
                        // and an error has been reported elsewhere.
                        arg := operand{mode: variable, expr: x.expr, typ: recv}
-                       targs := check.infer(m.pos, sig.RParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
+                       targs := check.infer(m.pos, sig.RecvTypeParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
                        //check.dump("### inferred targs = %s", targs)
                        if targs == nil {
                                // We may reach here if there were other errors (see issue #40056).
@@ -574,7 +574,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr) {
                        // (If we modify m, some tests will fail; possibly because the m is in use.)
                        // TODO(gri) investigate and provide a correct explanation here
                        copy := *m
-                       copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RParams().list(), targs), nil)
+                       copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RecvTypeParams().list(), targs), nil)
                        obj = &copy
                }
                // TODO(gri) we also need to do substitution for parameterized interface methods
index 67cdc1e68aef575f79628e367cf1c292f7d861b0..81bac7b6ff87cf408c77c55faedea6630b049e5a 100644 (file)
@@ -394,10 +394,10 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
                        // here. Exit early in this case to prevent an assertion
                        // failure in makeSubstMap.
                        // TODO(gri) Can we avoid this check by fixing the lengths?
-                       if len(ftyp.RParams().list()) != Vn.targs.Len() {
+                       if len(ftyp.RecvTypeParams().list()) != Vn.targs.Len() {
                                return
                        }
-                       ftyp = check.subst(nopos, ftyp, makeSubstMap(ftyp.RParams().list(), Vn.targs.list()), nil).(*Signature)
+                       ftyp = check.subst(nopos, ftyp, makeSubstMap(ftyp.RecvTypeParams().list(), Vn.targs.list()), nil).(*Signature)
                }
 
                // If the methods have type parameters we don't care whether they
@@ -416,9 +416,9 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
                        // unimplemented call so that we test this code if we
                        // enable method type parameters.
                        unimplemented()
-                       u.x.init(append(ftyp.RParams().list(), ftyp.TypeParams().list()...))
+                       u.x.init(append(ftyp.RecvTypeParams().list(), ftyp.TypeParams().list()...))
                } else {
-                       u.x.init(ftyp.RParams().list())
+                       u.x.init(ftyp.RecvTypeParams().list())
                }
                if !u.unify(ftyp, mtyp) {
                        return m, f
index eeaf1acbd60681db2e33f7e73e476da5b8b0c11f..009ac7701260bff8920b35fd416c6d79be4cd0d1 100644 (file)
@@ -59,11 +59,11 @@ func (s *Signature) TypeParams() *TypeParamList { return s.tparams }
 // SetTypeParams sets the type parameters of signature s.
 func (s *Signature) SetTypeParams(tparams []*TypeParam) { s.tparams = bindTParams(tparams) }
 
-// RParams returns the receiver type parameters of signature s, or nil.
-func (s *Signature) RParams() *TypeParamList { return s.rparams }
+// RecvTypeParams returns the receiver type parameters of signature s, or nil.
+func (s *Signature) RecvTypeParams() *TypeParamList { return s.rparams }
 
-// SetRParams sets the receiver type params of signature s.
-func (s *Signature) SetRParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
+// SetRecvTypeParams sets the receiver type params of signature s.
+func (s *Signature) SetRecvTypeParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
 
 // Params returns the parameters of signature s, or nil.
 func (s *Signature) Params() *Tuple { return s.params }
@@ -138,14 +138,14 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
                        }
                        // provide type parameter bounds
                        // - only do this if we have the right number (otherwise an error is reported elsewhere)
-                       if sig.RParams().Len() == len(recvTParams) {
+                       if sig.RecvTypeParams().Len() == len(recvTParams) {
                                // We have a list of *TypeNames but we need a list of Types.
-                               list := make([]Type, sig.RParams().Len())
-                               for i, t := range sig.RParams().list() {
+                               list := make([]Type, sig.RecvTypeParams().Len())
+                               for i, t := range sig.RecvTypeParams().list() {
                                        list[i] = t
                                }
                                smap := makeSubstMap(recvTParams, list)
-                               for i, tpar := range sig.RParams().list() {
+                               for i, tpar := range sig.RecvTypeParams().list() {
                                        bound := recvTParams[i].bound
                                        // bound is (possibly) parameterized in the context of the
                                        // receiver type declaration. Substitute parameters for the
@@ -213,7 +213,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
                                T.expand(nil)
                                // The receiver type may be an instantiated type referred to
                                // by an alias (which cannot have receiver parameters for now).
-                               if T.TypeArgs() != nil && sig.RParams() == nil {
+                               if T.TypeArgs() != nil && sig.RecvTypeParams() == nil {
                                        check.errorf(recv.pos, "cannot define methods on instantiated type %s", recv.typ)
                                        break
                                }
index 1fe139da17c2fe55d499e28c2c76f0bc6a1f7775..039fc6a61b483cf74e3e92ab55600910968adbbd 100644 (file)
@@ -339,7 +339,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))
index 3710756c29c24cb64a5878cb5d89c171520eabd1..4de5fed46e6772e8b9da4e6009048a1dc14cb32b 100644 (file)
@@ -537,7 +537,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
                // the signature accordingly.
                // TODO(gri) factor this code out
                sig := m.typ.(*Signature)
-               if sig.RParams().Len() > 0 {
+               if sig.RecvTypeParams().Len() > 0 {
                        // For inference to work, we must use the receiver type
                        // matching the receiver in the actual method declaration.
                        // If the method is embedded, the matching receiver is the
@@ -565,7 +565,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
                        // the receiver type arguments here, the receiver must be be otherwise invalid
                        // and an error has been reported elsewhere.
                        arg := operand{mode: variable, expr: x.expr, typ: recv}
-                       targs := check.infer(m, sig.RParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
+                       targs := check.infer(m, sig.RecvTypeParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
                        if targs == nil {
                                // We may reach here if there were other errors (see issue #40056).
                                goto Error
@@ -574,7 +574,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
                        // (If we modify m, some tests will fail; possibly because the m is in use.)
                        // TODO(gri) investigate and provide a correct explanation here
                        copy := *m
-                       copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RParams().list(), targs), nil)
+                       copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RecvTypeParams().list(), targs), nil)
                        obj = &copy
                }
                // TODO(gri) we also need to do substitution for parameterized interface methods
index f5bdd31a6f1bdeec88bb10ab0f8621e6fa473093..4664a0b33bf032b41884c9e96d9d777ee36ed1f2 100644 (file)
@@ -392,10 +392,10 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
                        // here. Exit early in this case to prevent an assertion
                        // failure in makeSubstMap.
                        // TODO(gri) Can we avoid this check by fixing the lengths?
-                       if len(ftyp.RParams().list()) != Vn.targs.Len() {
+                       if len(ftyp.RecvTypeParams().list()) != Vn.targs.Len() {
                                return
                        }
-                       ftyp = check.subst(token.NoPos, ftyp, makeSubstMap(ftyp.RParams().list(), Vn.targs.list()), nil).(*Signature)
+                       ftyp = check.subst(token.NoPos, ftyp, makeSubstMap(ftyp.RecvTypeParams().list(), Vn.targs.list()), nil).(*Signature)
                }
 
                // If the methods have type parameters we don't care whether they
@@ -404,7 +404,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
                // TODO(gri) is this always correct? what about type bounds?
                // (Alternative is to rename/subst type parameters and compare.)
                u := newUnifier(true)
-               u.x.init(ftyp.RParams().list())
+               u.x.init(ftyp.RecvTypeParams().list())
                if !u.unify(ftyp, mtyp) {
                        return m, f
                }
index ec2030a689f1530908b6786506f12a1c29f12e62..37811828eeb15764dfc53f952d7d6fe3ef72287c 100644 (file)
@@ -61,11 +61,11 @@ func (s *Signature) TypeParams() *TypeParamList { return s.tparams }
 // SetTypeParams sets the type parameters of signature s.
 func (s *Signature) SetTypeParams(tparams []*TypeParam) { s.tparams = bindTParams(tparams) }
 
-// RParams returns the receiver type parameters of signature s, or nil.
-func (s *Signature) RParams() *TypeParamList { return s.rparams }
+// RecvTypeParams returns the receiver type parameters of signature s, or nil.
+func (s *Signature) RecvTypeParams() *TypeParamList { return s.rparams }
 
-// SetRParams sets the receiver type params of signature s.
-func (s *Signature) SetRParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
+// SetRecvTypeParams sets the receiver type params of signature s.
+func (s *Signature) SetRecvTypeParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
 
 // Params returns the parameters of signature s, or nil.
 func (s *Signature) Params() *Tuple { return s.params }
@@ -133,14 +133,14 @@ func (check *Checker) funcType(sig *Signature, recvPar *ast.FieldList, ftyp *ast
                        }
                        // provide type parameter bounds
                        // - only do this if we have the right number (otherwise an error is reported elsewhere)
-                       if sig.RParams().Len() == len(recvTParams) {
+                       if sig.RecvTypeParams().Len() == len(recvTParams) {
                                // We have a list of *TypeNames but we need a list of Types.
-                               list := make([]Type, sig.RParams().Len())
-                               for i, t := range sig.RParams().list() {
+                               list := make([]Type, sig.RecvTypeParams().Len())
+                               for i, t := range sig.RecvTypeParams().list() {
                                        list[i] = t
                                }
                                smap := makeSubstMap(recvTParams, list)
-                               for i, tpar := range sig.RParams().list() {
+                               for i, tpar := range sig.RecvTypeParams().list() {
                                        bound := recvTParams[i].bound
                                        // bound is (possibly) parameterized in the context of the
                                        // receiver type declaration. Substitute parameters for the
@@ -203,7 +203,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *ast.FieldList, ftyp *ast
                                T.expand(nil)
                                // The receiver type may be an instantiated type referred to
                                // by an alias (which cannot have receiver parameters for now).
-                               if T.TypeArgs() != nil && sig.RParams() == nil {
+                               if T.TypeArgs() != nil && sig.RecvTypeParams() == nil {
                                        check.errorf(atPos(recv.pos), _Todo, "cannot define methods on instantiated type %s", recv.typ)
                                        break
                                }