Skip to content

Commit

Permalink
Fix implicit aliasing issue in nested maps
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamradhakrishnan committed May 8, 2023
1 parent 20b9845 commit a48b995
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
27 changes: 18 additions & 9 deletions pkg/deepcopy/testdata/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/deepcopy/traverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ func (c *copyMethodMaker) genMapDeepCopy(actualName *namingInfo, mapType *types.
c.IfElse("val == nil", func() {
c.Line("(*out)[key] = nil")
}, func() {
c.Line("in, out := &val, &outVal")
c.Line("inVal := (*in)[key]")
c.Line("in, out := &inVal, &outVal")
c.genDeepCopyIntoBlock(&namingInfo{typeInfo: mapType.Elem()}, mapType.Elem())
})
c.Line("(*out)[key] = outVal")
Expand Down

0 comments on commit a48b995

Please sign in to comment.