]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/types2: remove (*Signature).SetRecvTypeParams
authorMatthew Dempsky <mdempsky@google.com>
Wed, 26 Jan 2022 00:49:59 +0000 (16:49 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 26 Jan 2022 19:33:44 +0000 (19:33 +0000)
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 <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/reader2.go
src/cmd/compile/internal/types2/signature.go

index 9396c0c87c5e3501fd7ffbc4a025fc7ded331ef1..c028d21c673147863b0b728306f4c373d3d51b66 100644 (file)
@@ -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)
index 39161fcdf5ca884bbdccb5099e5e8e7191b8ca9a..c87fab749c6ccfaea54b36e09a37e7d3a54afb81 100644 (file)
@@ -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 }