Skip to content

Commit f9271e4

Browse files
committed
go/types, types2: rename RParams -> RecvTypeParams
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 <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent ea43445 commit f9271e4

File tree

11 files changed

+38
-38
lines changed

11 files changed

+38
-38
lines changed

src/cmd/compile/internal/importer/iimport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ func (r *importReader) obj(name string) {
349349
for i := range rparams {
350350
rparams[i] = types2.AsTypeParam(targs.At(i))
351351
}
352-
msig.SetRParams(rparams)
352+
msig.SetRecvTypeParams(rparams)
353353
}
354354

355355
named.AddMethod(types2.NewFunc(mpos, r.currPkg, mname, msig))

src/cmd/compile/internal/noder/reader2.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func (r *reader2) method() *types2.Func {
492492

493493
rparams := r.typeParamNames()
494494
sig := r.signature(r.param())
495-
sig.SetRParams(rparams)
495+
sig.SetRecvTypeParams(rparams)
496496

497497
_ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go.
498498
return types2.NewFunc(pos, pkg, name, sig)

src/cmd/compile/internal/noder/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func (g *irgen) fillinMethods(typ *types2.Named, ntyp *types.Type) {
309309
meth2 = newsym.Def.(*ir.Name)
310310
} else {
311311
meth2 = ir.NewNameAt(meth.Pos(), newsym)
312-
rparams := types2.AsSignature(m.Type()).RParams()
312+
rparams := types2.AsSignature(m.Type()).RecvTypeParams()
313313
tparams := make([]*types.Type, rparams.Len())
314314
for i := range tparams {
315315
tparams[i] = g.typ1(rparams.At(i))

src/cmd/compile/internal/noder/writer.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ func (w *writer) method(wext *writer, meth *types2.Func) {
648648
w.sync(syncMethod)
649649
w.pos(meth)
650650
w.selector(meth)
651-
w.typeParamNames(sig.RParams())
651+
w.typeParamNames(sig.RecvTypeParams())
652652
w.param(sig.Recv())
653653
w.signature(sig)
654654

@@ -1665,7 +1665,7 @@ func (w *writer) pkgDecl(decl syntax.Decl) {
16651665
obj := w.p.info.Defs[decl.Name].(*types2.Func)
16661666
sig := obj.Type().(*types2.Signature)
16671667

1668-
if sig.RParams() != nil || sig.TypeParams() != nil {
1668+
if sig.RecvTypeParams() != nil || sig.TypeParams() != nil {
16691669
break // skip generic functions
16701670
}
16711671

@@ -1851,7 +1851,7 @@ func objTypeParams(obj types2.Object) *types2.TypeParamList {
18511851
case *types2.Func:
18521852
sig := obj.Type().(*types2.Signature)
18531853
if sig.Recv() != nil {
1854-
return sig.RParams()
1854+
return sig.RecvTypeParams()
18551855
}
18561856
return sig.TypeParams()
18571857
case *types2.TypeName:

src/cmd/compile/internal/types2/call.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr) {
535535
// the signature accordingly.
536536
// TODO(gri) factor this code out
537537
sig := m.typ.(*Signature)
538-
if sig.RParams().Len() > 0 {
538+
if sig.RecvTypeParams().Len() > 0 {
539539
// For inference to work, we must use the receiver type
540540
// matching the receiver in the actual method declaration.
541541
// If the method is embedded, the matching receiver is the
@@ -564,7 +564,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr) {
564564
// the receiver type arguments here, the receiver must be be otherwise invalid
565565
// and an error has been reported elsewhere.
566566
arg := operand{mode: variable, expr: x.expr, typ: recv}
567-
targs := check.infer(m.pos, sig.RParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
567+
targs := check.infer(m.pos, sig.RecvTypeParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
568568
//check.dump("### inferred targs = %s", targs)
569569
if targs == nil {
570570
// 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) {
574574
// (If we modify m, some tests will fail; possibly because the m is in use.)
575575
// TODO(gri) investigate and provide a correct explanation here
576576
copy := *m
577-
copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RParams().list(), targs), nil)
577+
copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RecvTypeParams().list(), targs), nil)
578578
obj = &copy
579579
}
580580
// TODO(gri) we also need to do substitution for parameterized interface methods

src/cmd/compile/internal/types2/lookup.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
394394
// here. Exit early in this case to prevent an assertion
395395
// failure in makeSubstMap.
396396
// TODO(gri) Can we avoid this check by fixing the lengths?
397-
if len(ftyp.RParams().list()) != Vn.targs.Len() {
397+
if len(ftyp.RecvTypeParams().list()) != Vn.targs.Len() {
398398
return
399399
}
400-
ftyp = check.subst(nopos, ftyp, makeSubstMap(ftyp.RParams().list(), Vn.targs.list()), nil).(*Signature)
400+
ftyp = check.subst(nopos, ftyp, makeSubstMap(ftyp.RecvTypeParams().list(), Vn.targs.list()), nil).(*Signature)
401401
}
402402

403403
// 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,
416416
// unimplemented call so that we test this code if we
417417
// enable method type parameters.
418418
unimplemented()
419-
u.x.init(append(ftyp.RParams().list(), ftyp.TypeParams().list()...))
419+
u.x.init(append(ftyp.RecvTypeParams().list(), ftyp.TypeParams().list()...))
420420
} else {
421-
u.x.init(ftyp.RParams().list())
421+
u.x.init(ftyp.RecvTypeParams().list())
422422
}
423423
if !u.unify(ftyp, mtyp) {
424424
return m, f

src/cmd/compile/internal/types2/signature.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ func (s *Signature) TypeParams() *TypeParamList { return s.tparams }
5959
// SetTypeParams sets the type parameters of signature s.
6060
func (s *Signature) SetTypeParams(tparams []*TypeParam) { s.tparams = bindTParams(tparams) }
6161

62-
// RParams returns the receiver type parameters of signature s, or nil.
63-
func (s *Signature) RParams() *TypeParamList { return s.rparams }
62+
// RecvTypeParams returns the receiver type parameters of signature s, or nil.
63+
func (s *Signature) RecvTypeParams() *TypeParamList { return s.rparams }
6464

65-
// SetRParams sets the receiver type params of signature s.
66-
func (s *Signature) SetRParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
65+
// SetRecvTypeParams sets the receiver type params of signature s.
66+
func (s *Signature) SetRecvTypeParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
6767

6868
// Params returns the parameters of signature s, or nil.
6969
func (s *Signature) Params() *Tuple { return s.params }
@@ -138,14 +138,14 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
138138
}
139139
// provide type parameter bounds
140140
// - only do this if we have the right number (otherwise an error is reported elsewhere)
141-
if sig.RParams().Len() == len(recvTParams) {
141+
if sig.RecvTypeParams().Len() == len(recvTParams) {
142142
// We have a list of *TypeNames but we need a list of Types.
143-
list := make([]Type, sig.RParams().Len())
144-
for i, t := range sig.RParams().list() {
143+
list := make([]Type, sig.RecvTypeParams().Len())
144+
for i, t := range sig.RecvTypeParams().list() {
145145
list[i] = t
146146
}
147147
smap := makeSubstMap(recvTParams, list)
148-
for i, tpar := range sig.RParams().list() {
148+
for i, tpar := range sig.RecvTypeParams().list() {
149149
bound := recvTParams[i].bound
150150
// bound is (possibly) parameterized in the context of the
151151
// receiver type declaration. Substitute parameters for the
@@ -213,7 +213,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
213213
T.expand(nil)
214214
// The receiver type may be an instantiated type referred to
215215
// by an alias (which cannot have receiver parameters for now).
216-
if T.TypeArgs() != nil && sig.RParams() == nil {
216+
if T.TypeArgs() != nil && sig.RecvTypeParams() == nil {
217217
check.errorf(recv.pos, "cannot define methods on instantiated type %s", recv.typ)
218218
break
219219
}

src/go/internal/gcimporter/iimport.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ func (r *importReader) obj(name string) {
339339
for i := range rparams {
340340
rparams[i], _ = targs.At(i).(*types.TypeParam)
341341
}
342-
msig.SetRParams(rparams)
342+
msig.SetRecvTypeParams(rparams)
343343
}
344344

345345
named.AddMethod(types.NewFunc(mpos, r.currPkg, mname, msig))

src/go/types/call.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
537537
// the signature accordingly.
538538
// TODO(gri) factor this code out
539539
sig := m.typ.(*Signature)
540-
if sig.RParams().Len() > 0 {
540+
if sig.RecvTypeParams().Len() > 0 {
541541
// For inference to work, we must use the receiver type
542542
// matching the receiver in the actual method declaration.
543543
// If the method is embedded, the matching receiver is the
@@ -565,7 +565,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
565565
// the receiver type arguments here, the receiver must be be otherwise invalid
566566
// and an error has been reported elsewhere.
567567
arg := operand{mode: variable, expr: x.expr, typ: recv}
568-
targs := check.infer(m, sig.RParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
568+
targs := check.infer(m, sig.RecvTypeParams().list(), nil, NewTuple(sig.recv), []*operand{&arg}, false /* no error reporting */)
569569
if targs == nil {
570570
// We may reach here if there were other errors (see issue #40056).
571571
goto Error
@@ -574,7 +574,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr) {
574574
// (If we modify m, some tests will fail; possibly because the m is in use.)
575575
// TODO(gri) investigate and provide a correct explanation here
576576
copy := *m
577-
copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RParams().list(), targs), nil)
577+
copy.typ = check.subst(e.Pos(), m.typ, makeSubstMap(sig.RecvTypeParams().list(), targs), nil)
578578
obj = &copy
579579
}
580580
// TODO(gri) we also need to do substitution for parameterized interface methods

src/go/types/lookup.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
392392
// here. Exit early in this case to prevent an assertion
393393
// failure in makeSubstMap.
394394
// TODO(gri) Can we avoid this check by fixing the lengths?
395-
if len(ftyp.RParams().list()) != Vn.targs.Len() {
395+
if len(ftyp.RecvTypeParams().list()) != Vn.targs.Len() {
396396
return
397397
}
398-
ftyp = check.subst(token.NoPos, ftyp, makeSubstMap(ftyp.RParams().list(), Vn.targs.list()), nil).(*Signature)
398+
ftyp = check.subst(token.NoPos, ftyp, makeSubstMap(ftyp.RecvTypeParams().list(), Vn.targs.list()), nil).(*Signature)
399399
}
400400

401401
// 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,
404404
// TODO(gri) is this always correct? what about type bounds?
405405
// (Alternative is to rename/subst type parameters and compare.)
406406
u := newUnifier(true)
407-
u.x.init(ftyp.RParams().list())
407+
u.x.init(ftyp.RecvTypeParams().list())
408408
if !u.unify(ftyp, mtyp) {
409409
return m, f
410410
}

src/go/types/signature.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ func (s *Signature) TypeParams() *TypeParamList { return s.tparams }
6161
// SetTypeParams sets the type parameters of signature s.
6262
func (s *Signature) SetTypeParams(tparams []*TypeParam) { s.tparams = bindTParams(tparams) }
6363

64-
// RParams returns the receiver type parameters of signature s, or nil.
65-
func (s *Signature) RParams() *TypeParamList { return s.rparams }
64+
// RecvTypeParams returns the receiver type parameters of signature s, or nil.
65+
func (s *Signature) RecvTypeParams() *TypeParamList { return s.rparams }
6666

67-
// SetRParams sets the receiver type params of signature s.
68-
func (s *Signature) SetRParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
67+
// SetRecvTypeParams sets the receiver type params of signature s.
68+
func (s *Signature) SetRecvTypeParams(rparams []*TypeParam) { s.rparams = bindTParams(rparams) }
6969

7070
// Params returns the parameters of signature s, or nil.
7171
func (s *Signature) Params() *Tuple { return s.params }
@@ -133,14 +133,14 @@ func (check *Checker) funcType(sig *Signature, recvPar *ast.FieldList, ftyp *ast
133133
}
134134
// provide type parameter bounds
135135
// - only do this if we have the right number (otherwise an error is reported elsewhere)
136-
if sig.RParams().Len() == len(recvTParams) {
136+
if sig.RecvTypeParams().Len() == len(recvTParams) {
137137
// We have a list of *TypeNames but we need a list of Types.
138-
list := make([]Type, sig.RParams().Len())
139-
for i, t := range sig.RParams().list() {
138+
list := make([]Type, sig.RecvTypeParams().Len())
139+
for i, t := range sig.RecvTypeParams().list() {
140140
list[i] = t
141141
}
142142
smap := makeSubstMap(recvTParams, list)
143-
for i, tpar := range sig.RParams().list() {
143+
for i, tpar := range sig.RecvTypeParams().list() {
144144
bound := recvTParams[i].bound
145145
// bound is (possibly) parameterized in the context of the
146146
// receiver type declaration. Substitute parameters for the
@@ -203,7 +203,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *ast.FieldList, ftyp *ast
203203
T.expand(nil)
204204
// The receiver type may be an instantiated type referred to
205205
// by an alias (which cannot have receiver parameters for now).
206-
if T.TypeArgs() != nil && sig.RParams() == nil {
206+
if T.TypeArgs() != nil && sig.RecvTypeParams() == nil {
207207
check.errorf(atPos(recv.pos), _Todo, "cannot define methods on instantiated type %s", recv.typ)
208208
break
209209
}

0 commit comments

Comments
 (0)