reflect/protoreflect: add {Message,List,Map}.IsValid

Various protoreflect methods can return an "empty, read-only" message,
list, or map value. Provide a method to test if a value is one of these.

Fixes golang/protobuf#966

Change-Id: I793d8426d6e2201755983c06f024412a7e09bc4c
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/209018
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/internal/testprotos/irregular/irregular.go b/internal/testprotos/irregular/irregular.go
index 69220ba..4240124 100644
--- a/internal/testprotos/irregular/irregular.go
+++ b/internal/testprotos/irregular/irregular.go
@@ -82,6 +82,10 @@
 func (m *message) GetUnknown() pref.RawFields { return nil }
 func (m *message) SetUnknown(pref.RawFields)  { return }
 
+func (m *message) IsValid() bool {
+	return m != nil
+}
+
 var fileDesc = func() pref.FileDescriptor {
 	p := &descriptorpb.FileDescriptorProto{}
 	if err := prototext.Unmarshal([]byte(descriptorText), p); err != nil {