all: add ProtoMethods method to protoreflect.Message

Promote the fast-path magic ProtoMethods method to first-class citizen
of the protoreflect.Message interface.

To avoid polluting the protoreflect package with the various types
required by this method, make the necessary protoiface types unnamed and
duplicate them in protoreflect.

Updates golang/protobuf#1022.

Change-Id: I9595bae40b3bc7536d727fb6f99b3bce8f73da87
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/215718
Reviewed-by: Joe Tsai <joetsai@google.com>
diff --git a/runtime/protoiface/methods.go b/runtime/protoiface/methods.go
index b7ba129..4b9bb92 100644
--- a/runtime/protoiface/methods.go
+++ b/runtime/protoiface/methods.go
@@ -12,18 +12,10 @@
 import (
 	"google.golang.org/protobuf/internal/pragma"
 	"google.golang.org/protobuf/reflect/protoreflect"
-	"google.golang.org/protobuf/reflect/protoregistry"
 )
 
-// Methoder is an optional interface implemented by protoreflect.Message to
-// provide fast-path implementations of various operations.
-// The returned Methods struct must not be mutated.
-type Methoder interface {
-	ProtoMethods() *Methods // may return nil
-}
-
 // Methods is a set of optional fast-path implementations of various operations.
-type Methods struct {
+type Methods = struct {
 	pragma.NoUnkeyedLiterals
 
 	// Flags indicate support for optional features.
@@ -46,7 +38,7 @@
 	IsInitialized func(m protoreflect.Message) error
 }
 
-type SupportFlags uint64
+type SupportFlags = uint64
 
 const (
 	// SupportMarshalDeterministic reports whether MarshalOptions.Deterministic is supported.
@@ -59,7 +51,7 @@
 // MarshalOptions configure the marshaler.
 //
 // This type is identical to the one in package proto.
-type MarshalOptions struct {
+type MarshalOptions = struct {
 	pragma.NoUnkeyedLiterals
 
 	AllowPartial  bool // must be treated as true by method implementations
@@ -70,13 +62,14 @@
 // UnmarshalOptions configures the unmarshaler.
 //
 // This type is identical to the one in package proto.
-type UnmarshalOptions struct {
+type UnmarshalOptions = struct {
 	pragma.NoUnkeyedLiterals
 
 	Merge          bool // must be treated as true by method implementations
 	AllowPartial   bool // must be treated as true by method implementations
 	DiscardUnknown bool
 	Resolver       interface {
-		protoregistry.ExtensionTypeResolver
+		FindExtensionByName(field protoreflect.FullName) (protoreflect.ExtensionType, error)
+		FindExtensionByNumber(message protoreflect.FullName, field protoreflect.FieldNumber) (protoreflect.ExtensionType, error)
 	}
 }