From b14db5d943b84be3c9f3a909c18c9af4012523dd Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Fri, 17 Sep 2021 16:43:57 -0700 Subject: [PATCH] util/codegen: reorder AssertStructUnchanged args The fully qualified name of the type is thisPkg.tname, so write the args like that too. Suggested-by: Joe Tsai Signed-off-by: Josh Bleecher Snyder --- cmd/cloner/cloner.go | 2 +- util/codegen/codegen.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/cloner/cloner.go b/cmd/cloner/cloner.go index 123529f95..f24632eee 100644 --- a/cmd/cloner/cloner.go +++ b/cmd/cloner/cloner.go @@ -218,7 +218,7 @@ func gen(buf *bytes.Buffer, imports map[string]struct{}, typ *types.Named, thisP writef("return dst") fmt.Fprintf(buf, "}\n\n") - buf.Write(codegen.AssertStructUnchanged(t, name, "Clone", thisPkg, imports)) + buf.Write(codegen.AssertStructUnchanged(t, thisPkg, name, "Clone", imports)) } func hasBasicUnderlying(typ types.Type) bool { diff --git a/util/codegen/codegen.go b/util/codegen/codegen.go index 2df6c9b25..4265806ee 100644 --- a/util/codegen/codegen.go +++ b/util/codegen/codegen.go @@ -72,12 +72,12 @@ func NamedTypes(pkg *packages.Package) map[string]*types.Named { } // AssertStructUnchanged generates code that asserts at compile time that type t is unchanged. +// thisPkg is the package containing t. // tname is the named type corresponding to t. // ctx is a single-word context for this assertion, such as "Clone". -// thisPkg is the package containing t. // If non-nil, AssertStructUnchanged will add elements to imports // for each package path that the caller must import for the returned code to compile. -func AssertStructUnchanged(t *types.Struct, tname, ctx string, thisPkg *types.Package, imports map[string]struct{}) []byte { +func AssertStructUnchanged(t *types.Struct, thisPkg *types.Package, tname, ctx string, imports map[string]struct{}) []byte { buf := new(bytes.Buffer) w := func(format string, args ...interface{}) { fmt.Fprintf(buf, format+"\n", args...)