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.
parent 903a2db9
......@@ -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_<method> 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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment