From 8cfbb58bc70b9f9126a3310ac564344cc08c604b Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Tue, 25 Jan 2022 16:49:59 -0800 Subject: [PATCH] cmd/compile/internal/types2: remove (*Signature).SetRecvTypeParams This method isn't available in go/types, and its use by unified IR is non-essential. This CL refactors reader2.go to avoid using it and then removes the method. Change-Id: I813c93a062c43292bb6760686ef91df5219534a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/380834 Run-TryBot: Matthew Dempsky TryBot-Result: Gopher Robot Trust: Matthew Dempsky Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/noder/reader2.go | 16 +++++++--------- src/cmd/compile/internal/types2/signature.go | 3 --- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/cmd/compile/internal/noder/reader2.go b/src/cmd/compile/internal/noder/reader2.go index 9396c0c87c..c028d21c67 100644 --- a/src/cmd/compile/internal/noder/reader2.go +++ b/src/cmd/compile/internal/noder/reader2.go @@ -250,7 +250,7 @@ func (r *reader2) doTyp() (res types2.Type) { case typePointer: return types2.NewPointer(r.typ()) case typeSignature: - return r.signature(nil) + return r.signature(nil, nil, nil) case typeSlice: return types2.NewSlice(r.typ()) case typeStruct: @@ -298,7 +298,7 @@ func (r *reader2) interfaceType() *types2.Interface { for i := range methods { pos := r.pos() pkg, name := r.selector() - mtyp := r.signature(nil) + mtyp := r.signature(nil, nil, nil) methods[i] = types2.NewFunc(pos, pkg, name, mtyp) } @@ -309,14 +309,14 @@ func (r *reader2) interfaceType() *types2.Interface { return types2.NewInterfaceType(methods, embeddeds) } -func (r *reader2) signature(recv *types2.Var) *types2.Signature { +func (r *reader2) signature(recv *types2.Var, rtparams, tparams []*types2.TypeParam) *types2.Signature { r.sync(syncSignature) params := r.params() results := r.params() variadic := r.bool() - return types2.NewSignatureType(recv, nil, nil, params, results, variadic) + return types2.NewSignatureType(recv, rtparams, tparams, params, results, variadic) } func (r *reader2) params() *types2.Tuple { @@ -393,8 +393,7 @@ func (pr *pkgReader2) objIdx(idx int) (*types2.Package, string) { case objFunc: pos := r.pos() tparams := r.typeParamNames() - sig := r.signature(nil) - sig.SetTypeParams(tparams) + sig := r.signature(nil, nil, tparams) return types2.NewFunc(pos, objPkg, objName, sig) case objType: @@ -490,9 +489,8 @@ func (r *reader2) method() *types2.Func { pos := r.pos() pkg, name := r.selector() - rparams := r.typeParamNames() - sig := r.signature(r.param()) - sig.SetRecvTypeParams(rparams) + rtparams := r.typeParamNames() + sig := r.signature(r.param(), rtparams, nil) _ = r.pos() // TODO(mdempsky): Remove; this is a hacker for linker.go. return types2.NewFunc(pos, pkg, name, sig) diff --git a/src/cmd/compile/internal/types2/signature.go b/src/cmd/compile/internal/types2/signature.go index 39161fcdf5..c87fab749c 100644 --- a/src/cmd/compile/internal/types2/signature.go +++ b/src/cmd/compile/internal/types2/signature.go @@ -73,9 +73,6 @@ func (s *Signature) SetTypeParams(tparams []*TypeParam) { s.tparams = bindTParam // RecvTypeParams returns the receiver type parameters of signature s, or nil. func (s *Signature) RecvTypeParams() *TypeParamList { return s.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 } -- 2.50.0