• Joe Tsai's avatar
    encoding/json: error when trying to set an embedded pointer to unexported struct types · 70f441bc
    Joe Tsai authored
    This CL reverts CL 76851 and takes a different approach to #21357.
    The changes in encode.go and encode_test.go are reverts that
    rolls back the changed behavior in CL 76851 where
    embedded pointers to unexported struct types were
    unilaterally ignored in both marshal and unmarshal.
    
    Instead, these fields are handled as before with the exception that
    it returns an error when Unmarshal is unable to set an unexported field.
    The behavior of Marshal is now unchanged with regards to #21357.
    
    This policy maintains the greatest degree of backwards compatibility
    and avoids silently discarding data the user may have expected to be present.
    
    Fixes #21357
    
    Change-Id: I7dc753280c99f786ac51acf7e6c0246618c8b2b1
    Reviewed-on: https://go-review.googlesource.com/82135
    Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    70f441bc
encode_test.go 22.9 KB