]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix type substituter to copy Funarg value for structs
authorDan Scales <danscales@google.com>
Tue, 7 Sep 2021 14:46:27 +0000 (07:46 -0700)
committerDan Scales <danscales@google.com>
Tue, 7 Sep 2021 18:37:34 +0000 (18:37 +0000)
We were missing copying the Funarg value when substituting for a struct
type.

Change-Id: Id0c2d9e55fb15987acb9edba6f74cf57cfd3417e
Reviewed-on: https://go-review.googlesource.com/c/go/+/347913
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

src/cmd/compile/internal/typecheck/subr.go

index 4696b62cd2b863c5cf1b0d69a9bbc8921894e900..d0ae529596eb4cd7fde18a07e0ba613628d900e8 100644 (file)
@@ -1229,7 +1229,7 @@ func (ts *Tsubster) typ1(t *types.Type) *types.Type {
                newt = forw
        }
 
-       if !newt.HasTParam() {
+       if !newt.HasTParam() && !newt.IsFuncArgStruct() {
                // Calculate the size of any new types created. These will be
                // deferred until the top-level ts.Typ() or g.typ() (if this is
                // called from g.fillinMethods()).
@@ -1324,7 +1324,9 @@ func (ts *Tsubster) tstruct(t *types.Type, force bool) *types.Type {
                }
        }
        if newfields != nil {
-               return types.NewStruct(t.Pkg(), newfields)
+               news := types.NewStruct(t.Pkg(), newfields)
+               news.StructType().Funarg = t.StructType().Funarg
+               return news
        }
        return t