reflect: allow PtrValue.PointTo(nil)
(Argument: For any *PtrValue p, it should
always be possible to do: p.PointTo(p.Elem()),
even if p.Elem() is nil.)
Fixes #1028.
R=rsc
CC=golang-dev, r
https://golang.org/cl/1938044
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go
index 16b5ef6..dc01890 100644
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -384,6 +384,13 @@
if *ip != 1234 {
t.Errorf("got %d, want 1234", *ip)
}
+
+ ip = nil
+ vp := NewValue(ip).(*PtrValue)
+ vp.PointTo(vp.Elem())
+ if ip != nil {
+ t.Errorf("got non-nil (%p), want nil", ip)
+ }
}
func TestPtrSetNil(t *testing.T) {