reflect/protoregistry: add (*Types).Register{Message,Enum,Extension}

Add type-safe methods to register message, enum, and extension types.
Deprecate the NewTypes function and the (*Types).Register method.

Add (*File).RegisterFile and deprecate the NewFiles function and
the (*File).Register method.

Updates golang/protobuf#963

Change-Id: Ie89e77526e0874539e9bd929ca0ba8d758e65a6e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/199898
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/impl/message_reflect_test.go b/internal/impl/message_reflect_test.go
index c5a4a6a..82d5f81 100644
--- a/internal/impl/message_reflect_test.go
+++ b/internal/impl/message_reflect_test.go
@@ -990,7 +990,7 @@
 			{name:"F7Entry" field:[{name:"key" number:1 label:LABEL_OPTIONAL type:TYPE_STRING}, {name:"value" number:2 label:LABEL_OPTIONAL type:TYPE_ENUM    type_name:".EnumProto3"}]   options:{map_entry:true}},
 			{name:"F8Entry" field:[{name:"key" number:1 label:LABEL_OPTIONAL type:TYPE_STRING}, {name:"value" number:2 label:LABEL_OPTIONAL type:TYPE_MESSAGE type_name:".ScalarProto3"}] options:{map_entry:true}}
 		]
-	`, protoregistry.NewFiles(
+	`, newFileRegistry(
 	EnumProto2(0).Descriptor().ParentFile(),
 	EnumProto3(0).Descriptor().ParentFile(),
 	((*ScalarProto2)(nil)).ProtoReflect().Descriptor().ParentFile(),
@@ -999,6 +999,14 @@
 )),
 }
 
+func newFileRegistry(files ...pref.FileDescriptor) *protoregistry.Files {
+	r := new(protoregistry.Files)
+	for _, file := range files {
+		r.RegisterFile(file)
+	}
+	return r
+}
+
 func (m *EnumMessages) ProtoReflect() pref.Message { return enumMessagesType.MessageOf(m) }
 
 func (*EnumMessages) XXX_OneofWrappers() []interface{} {