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.
This commit is contained in:
Clayton Coleman 2016-07-03 00:10:43 -04:00
parent 903a2db90a
commit 534075f828
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -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) {