diff options
| author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 15:41:54 +0000 |
|---|---|---|
| committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 15:41:54 +0000 |
| commit | 7da93e24295c8b313ecdcedee0b8bde70b335e61 (patch) | |
| tree | e3de46cbc89d82ca1f49843fe2e1e670db67795e /libgo/go/encoding/gob | |
| parent | f86a7907050666ce7cab2890b353619f83d6c98b (diff) | |
| download | ppe42-gcc-7da93e24295c8b313ecdcedee0b8bde70b335e61.tar.gz ppe42-gcc-7da93e24295c8b313ecdcedee0b8bde70b335e61.zip | |
libgo: Update to weekly.2011-12-06.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182338 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/encoding/gob')
| -rw-r--r-- | libgo/go/encoding/gob/encoder.go | 4 | ||||
| -rw-r--r-- | libgo/go/encoding/gob/encoder_test.go | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/libgo/go/encoding/gob/encoder.go b/libgo/go/encoding/gob/encoder.go index e4a48dfc4fc..a15b5a1f9a1 100644 --- a/libgo/go/encoding/gob/encoder.go +++ b/libgo/go/encoding/gob/encoder.go @@ -119,7 +119,9 @@ func (enc *Encoder) sendActualType(w io.Writer, state *encoderState, ut *userTyp switch st := actual; st.Kind() { case reflect.Struct: for i := 0; i < st.NumField(); i++ { - enc.sendType(w, state, st.Field(i).Type) + if isExported(st.Field(i).Name) { + enc.sendType(w, state, st.Field(i).Type) + } } case reflect.Array, reflect.Slice: enc.sendType(w, state, st.Elem()) diff --git a/libgo/go/encoding/gob/encoder_test.go b/libgo/go/encoding/gob/encoder_test.go index bc5af120af3..5bc957bb370 100644 --- a/libgo/go/encoding/gob/encoder_test.go +++ b/libgo/go/encoding/gob/encoder_test.go @@ -662,3 +662,19 @@ func TestSequentialDecoder(t *testing.T) { } } } + +// Should be able to have unrepresentable fields (chan, func) as long as they +// are unexported. +type Bug2 struct { + A int + b chan int +} + +func TestUnexportedChan(t *testing.T) { + b := Bug2{23, make(chan int)} + var stream bytes.Buffer + enc := NewEncoder(&stream) + if err := enc.Encode(b); err != nil { + t.Fatalf("error encoding unexported channel: %s", err) + } +} |

