goprotobuf: Introduce new proto.Message type.

Every generated protocol buffer type now implements the proto.Message interface,
which means we can add some compile-time type safety throughout the API
as well as drop a bunch of error cases.

R=r, rsc
CC=golang-dev
http://codereview.appspot.com/6298073
diff --git a/proto/extensions.go b/proto/extensions.go
index b9ba8b0..d3d5d5c 100644
--- a/proto/extensions.go
+++ b/proto/extensions.go
@@ -52,6 +52,7 @@
 
 // extendableProto is an interface implemented by any protocol buffer that may be extended.
 type extendableProto interface {
+	Message
 	ExtensionRangeArray() []ExtensionRange
 	ExtensionMap() map[int32]Extension
 }
@@ -59,7 +60,7 @@
 // ExtensionDesc represents an extension specification.
 // Used in generated code from the protocol compiler.
 type ExtensionDesc struct {
-	ExtendedType  interface{} // nil pointer to the type that is being extended
+	ExtendedType  Message     // nil pointer to the type that is being extended
 	ExtensionType interface{} // nil pointer to the extension type
 	Field         int32       // field number
 	Name          string      // fully-qualified name of extension, for text formatting
@@ -230,7 +231,7 @@
 
 // GetExtensions returns a slice of the extensions present in pb that are also listed in es.
 // The returned slice has the same length as es; missing extensions will appear as nil elements.
-func GetExtensions(pb interface{}, es []*ExtensionDesc) (extensions []interface{}, err error) {
+func GetExtensions(pb Message, es []*ExtensionDesc) (extensions []interface{}, err error) {
 	epb, ok := pb.(extendableProto)
 	if !ok {
 		err = errors.New("not an extendable proto")
@@ -282,6 +283,6 @@
 // RegisteredExtensions returns a map of the registered extensions of a
 // protocol buffer struct, indexed by the extension number.
 // The argument pb should be a nil pointer to the struct type.
-func RegisteredExtensions(pb interface{}) map[int32]*ExtensionDesc {
+func RegisteredExtensions(pb Message) map[int32]*ExtensionDesc {
 	return extensionMaps[reflect.TypeOf(pb).Elem()]
 }