all: add NewField, NewElement, NewValue

Add methods to protoreflect.{Message,List,Map} to constrict values
assignable to a message field, list element, or map value. These
methods return the default value for scalar fields, the zero value for
scalar list elements and map values, and an empty, mutable value for
messages, lists, and maps.

Deprecate the NewMessage methods on these types, which are superseded.

Updates golang/protobuf#879

Change-Id: I0f064f60c89a239330ccea81523f559f14fd2c4f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/188997
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/impl/message_field.go b/internal/impl/message_field.go
index e15b861..3dfac23 100644
--- a/internal/impl/message_field.go
+++ b/internal/impl/message_field.go
@@ -26,6 +26,7 @@
 	set        func(pointer, pref.Value)
 	mutable    func(pointer) pref.Value
 	newMessage func() pref.Message
+	newField   func() pref.Value
 }
 
 func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
@@ -113,6 +114,9 @@
 		newMessage: func() pref.Message {
 			return conv.New().Message()
 		},
+		newField: func() pref.Value {
+			return conv.New()
+		},
 	}
 }
 
@@ -160,6 +164,9 @@
 			}
 			return conv.PBValueOf(v)
 		},
+		newField: func() pref.Value {
+			return conv.New()
+		},
 	}
 }
 
@@ -204,6 +211,9 @@
 			v := p.Apply(fieldOffset).AsValueOf(fs.Type)
 			return conv.PBValueOf(v)
 		},
+		newField: func() pref.Value {
+			return conv.New()
+		},
 	}
 }
 
@@ -289,6 +299,9 @@
 				}
 			}
 		},
+		newField: func() pref.Value {
+			return conv.New()
+		},
 	}
 }
 
@@ -367,6 +380,10 @@
 			lazyInit()
 			return messageType.New()
 		},
+		newField: func() pref.Value {
+			lazyInit()
+			return pref.ValueOf(messageType.New())
+		},
 	}
 }
 
@@ -417,6 +434,9 @@
 		newMessage: func() pref.Message {
 			return conv.New().Message()
 		},
+		newField: func() pref.Value {
+			return conv.New()
+		},
 	}
 }