From 534075f828106a94122c5f001691d37ca9d3b4bc Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sun, 3 Jul 2016 00:10:43 -0400 Subject: [PATCH] Deep copy should always use existing functions that are not ignored While testing this fix in OpenShift it was discovered that the PackageConstraint was overly aggressive - types that declare a public copy function should always return true. PackageConstraint is intended to limit packages where we might generate deep copy function, rather than to prevent external packages from being consumed. --- cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go b/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go index faf4fa63722..edaf75627b3 100644 --- a/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go +++ b/cmd/libs/go2idl/deepcopy-gen/generators/deepcopy.go @@ -118,10 +118,12 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat // avoid having to make a reflection call. canInlineTypeFn := func(c *generator.Context, t *types.Type) bool { // types must be public structs or have a custom DeepCopy_ already defined - if !copyableWithinPackage(t, explicitInputs.Has(t.Name.Package)) && !publicCopyFunctionDefined(c, t) { + if publicCopyFunctionDefined(c, t) { + return true + } + if !copyableWithinPackage(t, explicitInputs.Has(t.Name.Package)) { return false } - // only packages within the restricted range can be inlined for _, s := range restrictRange { if strings.HasPrefix(t.Name.Package, s) {