Procházet zdrojové kódy

reflect/protoreflect: rename methods with Type suffix

The protobuf type system uses the word "descriptor" instead of "type".
We should avoid the "type" verbage when we aren't talking about Go types.
The old names are temporarily kept around for compatibility reasons.

Change-Id: Icc99c913528ead011f7a74aa8399d9c5ec6dc56e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/172238
Reviewed-by: Herbie Ong <herbie@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Joe Tsai před 6 roky
rodič
revize
d24bc72368

+ 27 - 27
cmd/protoc-gen-go-grpc/internal_gengogrpc/grpc.go

@@ -181,20 +181,20 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
 func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
 func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
 	s := method.GoName + "(ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context"))
 	s := method.GoName + "(ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context"))
 	if !method.Desc.IsStreamingClient() {
 	if !method.Desc.IsStreamingClient() {
-		s += ", in *" + g.QualifiedGoIdent(method.InputType.GoIdent)
+		s += ", in *" + g.QualifiedGoIdent(method.Input.GoIdent)
 	}
 	}
 	s += ", opts ..." + g.QualifiedGoIdent(grpcPackage.Ident("CallOption")) + ") ("
 	s += ", opts ..." + g.QualifiedGoIdent(grpcPackage.Ident("CallOption")) + ") ("
 	if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
 	if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
-		s += "*" + g.QualifiedGoIdent(method.OutputType.GoIdent)
+		s += "*" + g.QualifiedGoIdent(method.Output.GoIdent)
 	} else {
 	} else {
-		s += method.ParentService.GoName + "_" + method.GoName + "Client"
+		s += method.Parent.GoName + "_" + method.GoName + "Client"
 	}
 	}
 	s += ", error)"
 	s += ", error)"
 	return s
 	return s
 }
 }
 
 
 func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
 func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
-	service := method.ParentService
+	service := method.Parent
 	sname := fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.Desc.Name())
 	sname := fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.Desc.Name())
 
 
 	if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
 	if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
@@ -202,7 +202,7 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 	}
 	}
 	g.P("func (c *", unexport(service.GoName), "Client) ", clientSignature(g, method), "{")
 	g.P("func (c *", unexport(service.GoName), "Client) ", clientSignature(g, method), "{")
 	if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() {
 	if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() {
-		g.P("out := new(", method.OutputType.GoIdent, ")")
+		g.P("out := new(", method.Output.GoIdent, ")")
 		g.P(`err := c.cc.Invoke(ctx, "`, sname, `", in, out, opts...)`)
 		g.P(`err := c.cc.Invoke(ctx, "`, sname, `", in, out, opts...)`)
 		g.P("if err != nil { return nil, err }")
 		g.P("if err != nil { return nil, err }")
 		g.P("return out, nil")
 		g.P("return out, nil")
@@ -230,13 +230,13 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 	// Stream auxiliary types and methods.
 	// Stream auxiliary types and methods.
 	g.P("type ", service.GoName, "_", method.GoName, "Client interface {")
 	g.P("type ", service.GoName, "_", method.GoName, "Client interface {")
 	if genSend {
 	if genSend {
-		g.P("Send(*", method.InputType.GoIdent, ") error")
+		g.P("Send(*", method.Input.GoIdent, ") error")
 	}
 	}
 	if genRecv {
 	if genRecv {
-		g.P("Recv() (*", method.OutputType.GoIdent, ", error)")
+		g.P("Recv() (*", method.Output.GoIdent, ", error)")
 	}
 	}
 	if genCloseAndRecv {
 	if genCloseAndRecv {
-		g.P("CloseAndRecv() (*", method.OutputType.GoIdent, ", error)")
+		g.P("CloseAndRecv() (*", method.Output.GoIdent, ", error)")
 	}
 	}
 	g.P(grpcPackage.Ident("ClientStream"))
 	g.P(grpcPackage.Ident("ClientStream"))
 	g.P("}")
 	g.P("}")
@@ -248,23 +248,23 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 	g.P()
 	g.P()
 
 
 	if genSend {
 	if genSend {
-		g.P("func (x *", streamType, ") Send(m *", method.InputType.GoIdent, ") error {")
+		g.P("func (x *", streamType, ") Send(m *", method.Input.GoIdent, ") error {")
 		g.P("return x.ClientStream.SendMsg(m)")
 		g.P("return x.ClientStream.SendMsg(m)")
 		g.P("}")
 		g.P("}")
 		g.P()
 		g.P()
 	}
 	}
 	if genRecv {
 	if genRecv {
-		g.P("func (x *", streamType, ") Recv() (*", method.OutputType.GoIdent, ", error) {")
-		g.P("m := new(", method.OutputType.GoIdent, ")")
+		g.P("func (x *", streamType, ") Recv() (*", method.Output.GoIdent, ", error) {")
+		g.P("m := new(", method.Output.GoIdent, ")")
 		g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
 		g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
 		g.P("return m, nil")
 		g.P("return m, nil")
 		g.P("}")
 		g.P("}")
 		g.P()
 		g.P()
 	}
 	}
 	if genCloseAndRecv {
 	if genCloseAndRecv {
-		g.P("func (x *", streamType, ") CloseAndRecv() (*", method.OutputType.GoIdent, ", error) {")
+		g.P("func (x *", streamType, ") CloseAndRecv() (*", method.Output.GoIdent, ", error) {")
 		g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
 		g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
-		g.P("m := new(", method.OutputType.GoIdent, ")")
+		g.P("m := new(", method.Output.GoIdent, ")")
 		g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
 		g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
 		g.P("return m, nil")
 		g.P("return m, nil")
 		g.P("}")
 		g.P("}")
@@ -277,24 +277,24 @@ func serverSignature(g *protogen.GeneratedFile, method *protogen.Method) string
 	ret := "error"
 	ret := "error"
 	if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
 	if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
 		reqArgs = append(reqArgs, g.QualifiedGoIdent(contextPackage.Ident("Context")))
 		reqArgs = append(reqArgs, g.QualifiedGoIdent(contextPackage.Ident("Context")))
-		ret = "(*" + g.QualifiedGoIdent(method.OutputType.GoIdent) + ", error)"
+		ret = "(*" + g.QualifiedGoIdent(method.Output.GoIdent) + ", error)"
 	}
 	}
 	if !method.Desc.IsStreamingClient() {
 	if !method.Desc.IsStreamingClient() {
-		reqArgs = append(reqArgs, "*"+g.QualifiedGoIdent(method.InputType.GoIdent))
+		reqArgs = append(reqArgs, "*"+g.QualifiedGoIdent(method.Input.GoIdent))
 	}
 	}
 	if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
 	if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
-		reqArgs = append(reqArgs, method.ParentService.GoName+"_"+method.GoName+"Server")
+		reqArgs = append(reqArgs, method.Parent.GoName+"_"+method.GoName+"Server")
 	}
 	}
 	return method.GoName + "(" + strings.Join(reqArgs, ", ") + ") " + ret
 	return method.GoName + "(" + strings.Join(reqArgs, ", ") + ") " + ret
 }
 }
 
 
 func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method) string {
 func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method) string {
-	service := method.ParentService
+	service := method.Parent
 	hname := fmt.Sprintf("_%s_%s_Handler", service.GoName, method.GoName)
 	hname := fmt.Sprintf("_%s_%s_Handler", service.GoName, method.GoName)
 
 
 	if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
 	if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
 		g.P("func ", hname, "(srv interface{}, ctx ", contextPackage.Ident("Context"), ", dec func(interface{}) error, interceptor ", grpcPackage.Ident("UnaryServerInterceptor"), ") (interface{}, error) {")
 		g.P("func ", hname, "(srv interface{}, ctx ", contextPackage.Ident("Context"), ", dec func(interface{}) error, interceptor ", grpcPackage.Ident("UnaryServerInterceptor"), ") (interface{}, error) {")
-		g.P("in := new(", method.InputType.GoIdent, ")")
+		g.P("in := new(", method.Input.GoIdent, ")")
 		g.P("if err := dec(in); err != nil { return nil, err }")
 		g.P("if err := dec(in); err != nil { return nil, err }")
 		g.P("if interceptor == nil { return srv.(", service.GoName, "Server).", method.GoName, "(ctx, in) }")
 		g.P("if interceptor == nil { return srv.(", service.GoName, "Server).", method.GoName, "(ctx, in) }")
 		g.P("info := &", grpcPackage.Ident("UnaryServerInfo"), "{")
 		g.P("info := &", grpcPackage.Ident("UnaryServerInfo"), "{")
@@ -302,7 +302,7 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 		g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.GoName)), ",")
 		g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.GoName)), ",")
 		g.P("}")
 		g.P("}")
 		g.P("handler := func(ctx ", contextPackage.Ident("Context"), ", req interface{}) (interface{}, error) {")
 		g.P("handler := func(ctx ", contextPackage.Ident("Context"), ", req interface{}) (interface{}, error) {")
-		g.P("return srv.(", service.GoName, "Server).", method.GoName, "(ctx, req.(*", method.InputType.GoIdent, "))")
+		g.P("return srv.(", service.GoName, "Server).", method.GoName, "(ctx, req.(*", method.Input.GoIdent, "))")
 		g.P("}")
 		g.P("}")
 		g.P("return interceptor(ctx, in, info, handler)")
 		g.P("return interceptor(ctx, in, info, handler)")
 		g.P("}")
 		g.P("}")
@@ -312,7 +312,7 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 	streamType := unexport(service.GoName) + method.GoName + "Server"
 	streamType := unexport(service.GoName) + method.GoName + "Server"
 	g.P("func ", hname, "(srv interface{}, stream ", grpcPackage.Ident("ServerStream"), ") error {")
 	g.P("func ", hname, "(srv interface{}, stream ", grpcPackage.Ident("ServerStream"), ") error {")
 	if !method.Desc.IsStreamingClient() {
 	if !method.Desc.IsStreamingClient() {
-		g.P("m := new(", method.InputType.GoIdent, ")")
+		g.P("m := new(", method.Input.GoIdent, ")")
 		g.P("if err := stream.RecvMsg(m); err != nil { return err }")
 		g.P("if err := stream.RecvMsg(m); err != nil { return err }")
 		g.P("return srv.(", service.GoName, "Server).", method.GoName, "(m, &", streamType, "{stream})")
 		g.P("return srv.(", service.GoName, "Server).", method.GoName, "(m, &", streamType, "{stream})")
 	} else {
 	} else {
@@ -328,13 +328,13 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 	// Stream auxiliary types and methods.
 	// Stream auxiliary types and methods.
 	g.P("type ", service.GoName, "_", method.GoName, "Server interface {")
 	g.P("type ", service.GoName, "_", method.GoName, "Server interface {")
 	if genSend {
 	if genSend {
-		g.P("Send(*", method.OutputType.GoIdent, ") error")
+		g.P("Send(*", method.Output.GoIdent, ") error")
 	}
 	}
 	if genSendAndClose {
 	if genSendAndClose {
-		g.P("SendAndClose(*", method.OutputType.GoIdent, ") error")
+		g.P("SendAndClose(*", method.Output.GoIdent, ") error")
 	}
 	}
 	if genRecv {
 	if genRecv {
-		g.P("Recv() (*", method.InputType.GoIdent, ", error)")
+		g.P("Recv() (*", method.Input.GoIdent, ", error)")
 	}
 	}
 	g.P(grpcPackage.Ident("ServerStream"))
 	g.P(grpcPackage.Ident("ServerStream"))
 	g.P("}")
 	g.P("}")
@@ -346,20 +346,20 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
 	g.P()
 	g.P()
 
 
 	if genSend {
 	if genSend {
-		g.P("func (x *", streamType, ") Send(m *", method.OutputType.GoIdent, ") error {")
+		g.P("func (x *", streamType, ") Send(m *", method.Output.GoIdent, ") error {")
 		g.P("return x.ServerStream.SendMsg(m)")
 		g.P("return x.ServerStream.SendMsg(m)")
 		g.P("}")
 		g.P("}")
 		g.P()
 		g.P()
 	}
 	}
 	if genSendAndClose {
 	if genSendAndClose {
-		g.P("func (x *", streamType, ") SendAndClose(m *", method.OutputType.GoIdent, ") error {")
+		g.P("func (x *", streamType, ") SendAndClose(m *", method.Output.GoIdent, ") error {")
 		g.P("return x.ServerStream.SendMsg(m)")
 		g.P("return x.ServerStream.SendMsg(m)")
 		g.P("}")
 		g.P("}")
 		g.P()
 		g.P()
 	}
 	}
 	if genRecv {
 	if genRecv {
-		g.P("func (x *", streamType, ") Recv() (*", method.InputType.GoIdent, ", error) {")
-		g.P("m := new(", method.InputType.GoIdent, ")")
+		g.P("func (x *", streamType, ") Recv() (*", method.Input.GoIdent, ", error) {")
+		g.P("m := new(", method.Input.GoIdent, ")")
 		g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }")
 		g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }")
 		g.P("return m, nil")
 		g.P("return m, nil")
 		g.P("}")
 		g.P("}")

+ 31 - 31
cmd/protoc-gen-go/internal_gengo/main.go

@@ -350,13 +350,13 @@ func genMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, me
 	g.Annotate(message.GoIdent.GoName, message.Location)
 	g.Annotate(message.GoIdent.GoName, message.Location)
 	g.P("type ", message.GoIdent, " struct {")
 	g.P("type ", message.GoIdent, " struct {")
 	for _, field := range message.Fields {
 	for _, field := range message.Fields {
-		if field.OneofType != nil {
+		if field.Oneof != nil {
 			// It would be a bit simpler to iterate over the oneofs below,
 			// It would be a bit simpler to iterate over the oneofs below,
 			// but generating the field here keeps the contents of the Go
 			// but generating the field here keeps the contents of the Go
 			// struct in the same order as the contents of the source
 			// struct in the same order as the contents of the source
 			// .proto file.
 			// .proto file.
-			if field == field.OneofType.Fields[0] {
-				genOneofField(gen, g, f, message, field.OneofType)
+			if field == field.Oneof.Fields[0] {
+				genOneofField(gen, g, f, message, field.Oneof)
 			}
 			}
 			continue
 			continue
 		}
 		}
@@ -370,8 +370,8 @@ func genMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, me
 			fmt.Sprintf("json:%q", fieldJSONTag(field)),
 			fmt.Sprintf("json:%q", fieldJSONTag(field)),
 		}
 		}
 		if field.Desc.IsMap() {
 		if field.Desc.IsMap() {
-			key := field.MessageType.Fields[0]
-			val := field.MessageType.Fields[1]
+			key := field.Message.Fields[0]
+			val := field.Message.Fields[1]
 			tags = append(tags,
 			tags = append(tags,
 				fmt.Sprintf("protobuf_key:%q", fieldProtobufTag(key)),
 				fmt.Sprintf("protobuf_key:%q", fieldProtobufTag(key)),
 				fmt.Sprintf("protobuf_val:%q", fieldProtobufTag(val)),
 				fmt.Sprintf("protobuf_val:%q", fieldProtobufTag(val)),
@@ -459,9 +459,9 @@ func genMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, me
 			g.P("var ", defVarName, " []byte = []byte(", strconv.Quote(string(def.Bytes())), ")")
 			g.P("var ", defVarName, " []byte = []byte(", strconv.Quote(string(def.Bytes())), ")")
 		case protoreflect.EnumKind:
 		case protoreflect.EnumKind:
 			evalueDesc := field.Desc.DefaultEnumValue()
 			evalueDesc := field.Desc.DefaultEnumValue()
-			enum := field.EnumType
+			enum := field.Enum
 			evalue := enum.Values[evalueDesc.Index()]
 			evalue := enum.Values[evalueDesc.Index()]
-			g.P("const ", defVarName, " ", field.EnumType.GoIdent, " = ", evalue.GoIdent)
+			g.P("const ", defVarName, " ", field.Enum.GoIdent, " = ", evalue.GoIdent)
 		case protoreflect.FloatKind, protoreflect.DoubleKind:
 		case protoreflect.FloatKind, protoreflect.DoubleKind:
 			// Floating point numbers need extra handling for -Inf/Inf/NaN.
 			// Floating point numbers need extra handling for -Inf/Inf/NaN.
 			f := field.Desc.Default().Float()
 			f := field.Desc.Default().Float()
@@ -498,7 +498,7 @@ func genMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, me
 	// Getter methods.
 	// Getter methods.
 	for _, field := range message.Fields {
 	for _, field := range message.Fields {
 		if isFirstOneofField(field) {
 		if isFirstOneofField(field) {
-			genOneofGetter(gen, g, f, message, field.OneofType)
+			genOneofGetter(gen, g, f, message, field.Oneof)
 		}
 		}
 		goType, pointer := fieldGoType(g, field)
 		goType, pointer := fieldGoType(g, field)
 		defaultValue := fieldDefaultValue(g, message, field)
 		defaultValue := fieldDefaultValue(g, message, field)
@@ -507,8 +507,8 @@ func genMessage(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, me
 		}
 		}
 		g.Annotate(message.GoIdent.GoName+".Get"+field.GoName, field.Location)
 		g.Annotate(message.GoIdent.GoName+".Get"+field.GoName, field.Location)
 		g.P("func (x *", message.GoIdent, ") Get", field.GoName, "() ", goType, " {")
 		g.P("func (x *", message.GoIdent, ") Get", field.GoName, "() ", goType, " {")
-		if field.OneofType != nil {
-			g.P("if x, ok := x.Get", field.OneofType.GoName, "().(*", fieldOneofType(field), "); ok {")
+		if field.Oneof != nil {
+			g.P("if x, ok := x.Get", field.Oneof.GoName, "().(*", fieldOneofType(field), "); ok {")
 			g.P("return x.", field.GoName)
 			g.P("return x.", field.GoName)
 			g.P("}")
 			g.P("}")
 		} else {
 		} else {
@@ -549,7 +549,7 @@ func fieldGoType(g *protogen.GeneratedFile, field *protogen.Field) (goType strin
 	case protoreflect.BoolKind:
 	case protoreflect.BoolKind:
 		goType = "bool"
 		goType = "bool"
 	case protoreflect.EnumKind:
 	case protoreflect.EnumKind:
-		goType = g.QualifiedGoIdent(field.EnumType.GoIdent)
+		goType = g.QualifiedGoIdent(field.Enum.GoIdent)
 	case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
 	case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind:
 		goType = "int32"
 		goType = "int32"
 	case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
 	case protoreflect.Uint32Kind, protoreflect.Fixed32Kind:
@@ -569,11 +569,11 @@ func fieldGoType(g *protogen.GeneratedFile, field *protogen.Field) (goType strin
 		pointer = false
 		pointer = false
 	case protoreflect.MessageKind, protoreflect.GroupKind:
 	case protoreflect.MessageKind, protoreflect.GroupKind:
 		if field.Desc.IsMap() {
 		if field.Desc.IsMap() {
-			keyType, _ := fieldGoType(g, field.MessageType.Fields[0])
-			valType, _ := fieldGoType(g, field.MessageType.Fields[1])
+			keyType, _ := fieldGoType(g, field.Message.Fields[0])
+			valType, _ := fieldGoType(g, field.Message.Fields[1])
 			return fmt.Sprintf("map[%v]%v", keyType, valType), false
 			return fmt.Sprintf("map[%v]%v", keyType, valType), false
 		}
 		}
-		goType = "*" + g.QualifiedGoIdent(field.MessageType.GoIdent)
+		goType = "*" + g.QualifiedGoIdent(field.Message.GoIdent)
 		pointer = false
 		pointer = false
 	}
 	}
 	if field.Desc.Cardinality() == protoreflect.Repeated {
 	if field.Desc.Cardinality() == protoreflect.Repeated {
@@ -581,7 +581,7 @@ func fieldGoType(g *protogen.GeneratedFile, field *protogen.Field) (goType strin
 		pointer = false
 		pointer = false
 	}
 	}
 	// Extension fields always have pointer type, even when defined in a proto3 file.
 	// Extension fields always have pointer type, even when defined in a proto3 file.
-	if field.Desc.Syntax() == protoreflect.Proto3 && field.Desc.ExtendedType() == nil {
+	if field.Desc.Syntax() == protoreflect.Proto3 && field.Desc.Extendee() == nil {
 		pointer = false
 		pointer = false
 	}
 	}
 	return goType, pointer
 	return goType, pointer
@@ -590,7 +590,7 @@ func fieldGoType(g *protogen.GeneratedFile, field *protogen.Field) (goType strin
 func fieldProtobufTag(field *protogen.Field) string {
 func fieldProtobufTag(field *protogen.Field) string {
 	var enumName string
 	var enumName string
 	if field.Desc.Kind() == protoreflect.EnumKind {
 	if field.Desc.Kind() == protoreflect.EnumKind {
-		enumName = enumLegacyName(field.EnumType)
+		enumName = enumLegacyName(field.Enum)
 	}
 	}
 	return tag.Marshal(field.Desc, enumName)
 	return tag.Marshal(field.Desc, enumName)
 }
 }
@@ -614,7 +614,7 @@ func fieldDefaultValue(g *protogen.GeneratedFile, message *protogen.Message, fie
 	case protoreflect.MessageKind, protoreflect.GroupKind, protoreflect.BytesKind:
 	case protoreflect.MessageKind, protoreflect.GroupKind, protoreflect.BytesKind:
 		return "nil"
 		return "nil"
 	case protoreflect.EnumKind:
 	case protoreflect.EnumKind:
-		return g.QualifiedGoIdent(field.EnumType.Values[0].GoIdent)
+		return g.QualifiedGoIdent(field.Enum.Values[0].GoIdent)
 	default:
 	default:
 		return "0"
 		return "0"
 	}
 	}
@@ -645,7 +645,7 @@ func genExtensions(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo)
 		}
 		}
 
 
 		g.P("{")
 		g.P("{")
-		g.P("ExtendedType: (*", extension.ExtendedType.GoIdent, ")(nil),")
+		g.P("ExtendedType: (*", extension.Extendee.GoIdent, ")(nil),")
 		goType, pointer := fieldGoType(g, extension)
 		goType, pointer := fieldGoType(g, extension)
 		if pointer {
 		if pointer {
 			goType = "*" + goType
 			goType = "*" + goType
@@ -662,13 +662,13 @@ func genExtensions(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo)
 	g.P("var (")
 	g.P("var (")
 	for i, extension := range f.allExtensions {
 	for i, extension := range f.allExtensions {
 		ed := extension.Desc
 		ed := extension.Desc
-		targetName := string(ed.ExtendedType().FullName())
+		targetName := string(ed.Extendee().FullName())
 		typeName := ed.Kind().String()
 		typeName := ed.Kind().String()
 		switch ed.Kind() {
 		switch ed.Kind() {
 		case protoreflect.EnumKind:
 		case protoreflect.EnumKind:
-			typeName = string(ed.EnumType().FullName())
+			typeName = string(ed.Enum().FullName())
 		case protoreflect.MessageKind, protoreflect.GroupKind:
 		case protoreflect.MessageKind, protoreflect.GroupKind:
-			typeName = string(ed.MessageType().FullName())
+			typeName = string(ed.Message().FullName())
 		}
 		}
 		fieldName := string(ed.Name())
 		fieldName := string(ed.Name())
 		g.P("// extend ", targetName, " { ", ed.Cardinality().String(), " ", typeName, " ", fieldName, " = ", ed.Number(), "; }")
 		g.P("// extend ", targetName, " { ", ed.Cardinality().String(), " ", typeName, " ", fieldName, " = ", ed.Number(), "; }")
@@ -681,11 +681,11 @@ func genExtensions(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo)
 // isExtensionMessageSetELement returns the adjusted name of an extension
 // isExtensionMessageSetELement returns the adjusted name of an extension
 // which extends proto2.bridge.MessageSet.
 // which extends proto2.bridge.MessageSet.
 func isExtensionMessageSetElement(extension *protogen.Extension) (name protoreflect.FullName, ok bool) {
 func isExtensionMessageSetElement(extension *protogen.Extension) (name protoreflect.FullName, ok bool) {
-	opts := extension.ExtendedType.Desc.Options().(*descriptorpb.MessageOptions)
+	opts := extension.Extendee.Desc.Options().(*descriptorpb.MessageOptions)
 	if !opts.GetMessageSetWireFormat() || extension.Desc.Name() != "message_set_extension" {
 	if !opts.GetMessageSetWireFormat() || extension.Desc.Name() != "message_set_extension" {
 		return "", false
 		return "", false
 	}
 	}
-	if extension.ParentMessage == nil {
+	if extension.Parent == nil {
 		// This case shouldn't be given special handling at all--we're
 		// This case shouldn't be given special handling at all--we're
 		// only supposed to drop the ".message_set_extension" for
 		// only supposed to drop the ".message_set_extension" for
 		// extensions defined within a message (i.e., the extension
 		// extensions defined within a message (i.e., the extension
@@ -704,8 +704,8 @@ func isExtensionMessageSetElement(extension *protogen.Extension) (name protorefl
 // extensionVar returns the var holding the ExtensionDesc for an extension.
 // extensionVar returns the var holding the ExtensionDesc for an extension.
 func extensionVar(f *protogen.File, extension *protogen.Extension) protogen.GoIdent {
 func extensionVar(f *protogen.File, extension *protogen.Extension) protogen.GoIdent {
 	name := "E_"
 	name := "E_"
-	if extension.ParentMessage != nil {
-		name += extension.ParentMessage.GoIdent.GoName + "_"
+	if extension.Parent != nil {
+		name += extension.Parent.GoIdent.GoName + "_"
 	}
 	}
 	name += extension.GoName
 	name += extension.GoName
 	return f.GoImportPath.Ident(name)
 	return f.GoImportPath.Ident(name)
@@ -820,7 +820,7 @@ func genOneofTypes(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo,
 
 
 // isFirstOneofField reports whether this is the first field in a oneof.
 // isFirstOneofField reports whether this is the first field in a oneof.
 func isFirstOneofField(field *protogen.Field) bool {
 func isFirstOneofField(field *protogen.Field) bool {
-	return field.OneofType != nil && field.OneofType.Fields[0] == field
+	return field.Oneof != nil && field.Oneof.Fields[0] == field
 }
 }
 
 
 // oneofFieldName returns the name of the struct field holding the oneof value.
 // oneofFieldName returns the name of the struct field holding the oneof value.
@@ -834,14 +834,14 @@ func oneofFieldName(oneof *protogen.Oneof) string {
 // oneofInterfaceName returns the name of the interface type implemented by
 // oneofInterfaceName returns the name of the interface type implemented by
 // the oneof field value types.
 // the oneof field value types.
 func oneofInterfaceName(oneof *protogen.Oneof) string {
 func oneofInterfaceName(oneof *protogen.Oneof) string {
-	return fmt.Sprintf("is%s_%s", oneof.ParentMessage.GoIdent.GoName, oneof.GoName)
+	return fmt.Sprintf("is%s_%s", oneof.Parent.GoIdent.GoName, oneof.GoName)
 }
 }
 
 
 // fieldOneofType returns the wrapper type used to represent a field in a oneof.
 // fieldOneofType returns the wrapper type used to represent a field in a oneof.
 func fieldOneofType(field *protogen.Field) protogen.GoIdent {
 func fieldOneofType(field *protogen.Field) protogen.GoIdent {
 	ident := protogen.GoIdent{
 	ident := protogen.GoIdent{
-		GoImportPath: field.ParentMessage.GoIdent.GoImportPath,
-		GoName:       field.ParentMessage.GoIdent.GoName + "_" + field.GoName,
+		GoImportPath: field.Parent.GoIdent.GoImportPath,
+		GoName:       field.Parent.GoIdent.GoName + "_" + field.GoName,
 	}
 	}
 	// Check for collisions with nested messages or enums.
 	// Check for collisions with nested messages or enums.
 	//
 	//
@@ -853,13 +853,13 @@ func fieldOneofType(field *protogen.Field) protogen.GoIdent {
 	// field and type names in mostly unpredictable ways.
 	// field and type names in mostly unpredictable ways.
 Loop:
 Loop:
 	for {
 	for {
-		for _, message := range field.ParentMessage.Messages {
+		for _, message := range field.Parent.Messages {
 			if message.GoIdent == ident {
 			if message.GoIdent == ident {
 				ident.GoName += "_"
 				ident.GoName += "_"
 				continue Loop
 				continue Loop
 			}
 			}
 		}
 		}
-		for _, enum := range field.ParentMessage.Enums {
+		for _, enum := range field.Parent.Enums {
 			if enum.GoIdent == ident {
 			if enum.GoIdent == ident {
 				ident.GoName += "_"
 				ident.GoName += "_"
 				continue Loop
 				continue Loop

+ 7 - 7
cmd/protoc-gen-go/internal_gengo/reflect.go

@@ -82,7 +82,7 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f
 	}
 	}
 	for _, extension := range f.allExtensions {
 	for _, extension := range f.allExtensions {
 		source := string(extension.Desc.FullName())
 		source := string(extension.Desc.FullName())
-		genMessage(extension.ExtendedType, source+":extendee")
+		genMessage(extension.Extendee, source+":extendee")
 	}
 	}
 	for _, message := range f.allMessages {
 	for _, message := range f.allMessages {
 		for _, field := range message.Fields {
 		for _, field := range message.Fields {
@@ -90,20 +90,20 @@ func genReflectFileDescriptor(gen *protogen.Plugin, g *protogen.GeneratedFile, f
 				continue
 				continue
 			}
 			}
 			source := string(field.Desc.FullName())
 			source := string(field.Desc.FullName())
-			genEnum(field.EnumType, source+":type_name")
-			genMessage(field.MessageType, source+":type_name")
+			genEnum(field.Enum, source+":type_name")
+			genMessage(field.Message, source+":type_name")
 		}
 		}
 	}
 	}
 	for _, extension := range f.allExtensions {
 	for _, extension := range f.allExtensions {
 		source := string(extension.Desc.FullName())
 		source := string(extension.Desc.FullName())
-		genEnum(extension.EnumType, source+":type_name")
-		genMessage(extension.MessageType, source+":type_name")
+		genEnum(extension.Enum, source+":type_name")
+		genMessage(extension.Message, source+":type_name")
 	}
 	}
 	for _, service := range f.Services {
 	for _, service := range f.Services {
 		for _, method := range service.Methods {
 		for _, method := range service.Methods {
 			source := string(method.Desc.FullName())
 			source := string(method.Desc.FullName())
-			genMessage(method.InputType, source+":input_type")
-			genMessage(method.OutputType, source+":output_type")
+			genMessage(method.Input, source+":input_type")
+			genMessage(method.Output, source+":output_type")
 		}
 		}
 	}
 	}
 	if len(depIdxs) > math.MaxInt32 {
 	if len(depIdxs) > math.MaxInt32 {

+ 1 - 1
encoding/bench_test.go

@@ -125,7 +125,7 @@ func setList(list pref.List, fd pref.FieldDescriptor, level int) {
 }
 }
 
 
 func setMap(mmap pref.Map, fd pref.FieldDescriptor, level int) {
 func setMap(mmap pref.Map, fd pref.FieldDescriptor, level int) {
-	fields := fd.MessageType().Fields()
+	fields := fd.Message().Fields()
 	keyDesc := fields.ByNumber(1)
 	keyDesc := fields.ByNumber(1)
 	valDesc := fields.ByNumber(2)
 	valDesc := fields.ByNumber(2)
 
 

+ 5 - 5
encoding/jsonpb/decode.go

@@ -242,7 +242,7 @@ Loop:
 			}
 			}
 		} else {
 		} else {
 			// If field is a oneof, check if it has already been set.
 			// If field is a oneof, check if it has already been set.
-			if od := fd.OneofType(); od != nil {
+			if od := fd.Oneof(); od != nil {
 				idx := uint64(od.Index())
 				idx := uint64(od.Index())
 				if seenOneofs.Has(idx) {
 				if seenOneofs.Has(idx) {
 					return errors.New("%v: oneof is already set", od.FullName())
 					return errors.New("%v: oneof is already set", od.FullName())
@@ -276,12 +276,12 @@ func (o UnmarshalOptions) findExtension(xtName pref.FullName) (pref.ExtensionTyp
 }
 }
 
 
 func isKnownValue(fd pref.FieldDescriptor) bool {
 func isKnownValue(fd pref.FieldDescriptor) bool {
-	md := fd.MessageType()
+	md := fd.Message()
 	return md != nil && md.FullName() == "google.protobuf.Value"
 	return md != nil && md.FullName() == "google.protobuf.Value"
 }
 }
 
 
 func isNullValue(fd pref.FieldDescriptor) bool {
 func isNullValue(fd pref.FieldDescriptor) bool {
-	ed := fd.EnumType()
+	ed := fd.Enum()
 	return ed != nil && ed.FullName() == "google.protobuf.NullValue"
 	return ed != nil && ed.FullName() == "google.protobuf.NullValue"
 }
 }
 
 
@@ -506,7 +506,7 @@ func unmarshalEnum(jval json.Value, fd pref.FieldDescriptor) (pref.Value, error)
 	case json.String:
 	case json.String:
 		// Lookup EnumNumber based on name.
 		// Lookup EnumNumber based on name.
 		s := jval.String()
 		s := jval.String()
-		if enumVal := fd.EnumType().Values().ByName(pref.Name(s)); enumVal != nil {
+		if enumVal := fd.Enum().Values().ByName(pref.Name(s)); enumVal != nil {
 			return pref.ValueOf(enumVal.Number()), nil
 			return pref.ValueOf(enumVal.Number()), nil
 		}
 		}
 		return pref.Value{}, newError("invalid enum value %q", jval)
 		return pref.Value{}, newError("invalid enum value %q", jval)
@@ -602,7 +602,7 @@ func (o UnmarshalOptions) unmarshalMap(mmap pref.Map, fd pref.FieldDescriptor) e
 		return unexpectedJSONError{jval}
 		return unexpectedJSONError{jval}
 	}
 	}
 
 
-	fields := fd.MessageType().Fields()
+	fields := fd.Message().Fields()
 	keyDesc := fields.ByNumber(1)
 	keyDesc := fields.ByNumber(1)
 	valDesc := fields.ByNumber(2)
 	valDesc := fields.ByNumber(2)
 
 

+ 10 - 13
encoding/jsonpb/encode.go

@@ -178,19 +178,16 @@ func (o MarshalOptions) marshalSingular(val pref.Value, fd pref.FieldDescriptor)
 		}
 		}
 
 
 	case pref.EnumKind:
 	case pref.EnumKind:
-		enumType := fd.EnumType()
-		num := val.Enum()
-
-		if enumType.FullName() == "google.protobuf.NullValue" {
+		if fd.Enum().FullName() == "google.protobuf.NullValue" {
 			o.encoder.WriteNull()
 			o.encoder.WriteNull()
-		} else if desc := enumType.Values().ByNumber(num); desc != nil {
+		} else if desc := fd.Enum().Values().ByNumber(val.Enum()); desc != nil {
 			err := o.encoder.WriteString(string(desc.Name()))
 			err := o.encoder.WriteString(string(desc.Name()))
 			if !nerr.Merge(err) {
 			if !nerr.Merge(err) {
 				return err
 				return err
 			}
 			}
 		} else {
 		} else {
 			// Use numeric value if there is no enum value descriptor.
 			// Use numeric value if there is no enum value descriptor.
-			o.encoder.WriteInt(int64(num))
+			o.encoder.WriteInt(int64(val.Enum()))
 		}
 		}
 
 
 	case pref.MessageKind, pref.GroupKind:
 	case pref.MessageKind, pref.GroupKind:
@@ -229,7 +226,7 @@ func (o MarshalOptions) marshalMap(mmap pref.Map, fd pref.FieldDescriptor) error
 	o.encoder.StartObject()
 	o.encoder.StartObject()
 	defer o.encoder.EndObject()
 	defer o.encoder.EndObject()
 
 
-	msgFields := fd.MessageType().Fields()
+	msgFields := fd.Message().Fields()
 	keyType := msgFields.ByNumber(1)
 	keyType := msgFields.ByNumber(1)
 	valType := msgFields.ByNumber(2)
 	valType := msgFields.ByNumber(2)
 
 
@@ -286,7 +283,7 @@ func (o MarshalOptions) marshalExtensions(knownFields pref.KnownFields) error {
 		name := xt.FullName()
 		name := xt.FullName()
 		// If extended type is a MessageSet, set field name to be the message type name.
 		// If extended type is a MessageSet, set field name to be the message type name.
 		if isMessageSetExtension(xt) {
 		if isMessageSetExtension(xt) {
-			name = xt.MessageType().FullName()
+			name = xt.Message().FullName()
 		}
 		}
 
 
 		num := xt.Number()
 		num := xt.Number()
@@ -328,13 +325,13 @@ func isMessageSetExtension(xt pref.ExtensionType) bool {
 	if xt.Name() != "message_set_extension" {
 	if xt.Name() != "message_set_extension" {
 		return false
 		return false
 	}
 	}
-	mt := xt.MessageType()
-	if mt == nil {
+	md := xt.Message()
+	if md == nil {
 		return false
 		return false
 	}
 	}
-	if xt.FullName().Parent() != mt.FullName() {
+	if xt.FullName().Parent() != md.FullName() {
 		return false
 		return false
 	}
 	}
-	xmt, ok := xt.ExtendedType().(interface{ IsMessageSet() bool })
-	return ok && xmt.IsMessageSet()
+	xmd, ok := xt.Extendee().(interface{ IsMessageSet() bool })
+	return ok && xmd.IsMessageSet()
 }
 }

+ 3 - 3
encoding/textpb/decode.go

@@ -164,7 +164,7 @@ func (o UnmarshalOptions) unmarshalMessage(tmsg [][2]text.Value, m pref.Message)
 			}
 			}
 		} else {
 		} else {
 			// If field is a oneof, check if it has already been set.
 			// If field is a oneof, check if it has already been set.
-			if od := fd.OneofType(); od != nil {
+			if od := fd.Oneof(); od != nil {
 				idx := uint64(od.Index())
 				idx := uint64(od.Index())
 				if seenOneofs.Has(idx) {
 				if seenOneofs.Has(idx) {
 					return errors.New("oneof %v is already set", od.FullName())
 					return errors.New("oneof %v is already set", od.FullName())
@@ -313,7 +313,7 @@ func unmarshalScalar(input text.Value, fd pref.FieldDescriptor) (pref.Value, err
 		}
 		}
 		if name, ok := input.Name(); ok {
 		if name, ok := input.Name(); ok {
 			// Lookup EnumNumber based on name.
 			// Lookup EnumNumber based on name.
-			if enumVal := fd.EnumType().Values().ByName(name); enumVal != nil {
+			if enumVal := fd.Enum().Values().ByName(name); enumVal != nil {
 				return pref.ValueOf(enumVal.Number()), nil
 				return pref.ValueOf(enumVal.Number()), nil
 			}
 			}
 		}
 		}
@@ -356,7 +356,7 @@ func (o UnmarshalOptions) unmarshalList(inputList []text.Value, fd pref.FieldDes
 // unmarshalMap unmarshals given []text.Value into given protoreflect.Map.
 // unmarshalMap unmarshals given []text.Value into given protoreflect.Map.
 func (o UnmarshalOptions) unmarshalMap(input []text.Value, fd pref.FieldDescriptor, mmap pref.Map) error {
 func (o UnmarshalOptions) unmarshalMap(input []text.Value, fd pref.FieldDescriptor, mmap pref.Map) error {
 	var nerr errors.NonFatal
 	var nerr errors.NonFatal
-	fields := fd.MessageType().Fields()
+	fields := fd.Message().Fields()
 	keyDesc := fields.ByNumber(1)
 	keyDesc := fields.ByNumber(1)
 	valDesc := fields.ByNumber(2)
 	valDesc := fields.ByNumber(2)
 
 

+ 9 - 9
encoding/textpb/encode.go

@@ -101,7 +101,7 @@ func (o MarshalOptions) marshalMessage(m pref.Message) (text.Value, error) {
 		name := text.ValueOf(fd.Name())
 		name := text.ValueOf(fd.Name())
 		// Use type name for group field name.
 		// Use type name for group field name.
 		if fd.Kind() == pref.GroupKind {
 		if fd.Kind() == pref.GroupKind {
-			name = text.ValueOf(fd.MessageType().Name())
+			name = text.ValueOf(fd.Message().Name())
 		}
 		}
 		pval := knownFields.Get(num)
 		pval := knownFields.Get(num)
 		var err error
 		var err error
@@ -189,7 +189,7 @@ func (o MarshalOptions) marshalSingular(val pref.Value, fd pref.FieldDescriptor)
 
 
 	case pref.EnumKind:
 	case pref.EnumKind:
 		num := val.Enum()
 		num := val.Enum()
-		if desc := fd.EnumType().Values().ByNumber(num); desc != nil {
+		if desc := fd.Enum().Values().ByNumber(num); desc != nil {
 			return text.ValueOf(desc.Name()), nil
 			return text.ValueOf(desc.Name()), nil
 		}
 		}
 		// Use numeric value if there is no enum description.
 		// Use numeric value if there is no enum description.
@@ -231,7 +231,7 @@ func (o MarshalOptions) marshalMap(mmap pref.Map, fd pref.FieldDescriptor) ([]te
 	var nerr errors.NonFatal
 	var nerr errors.NonFatal
 	// values is a list of messages.
 	// values is a list of messages.
 	values := make([]text.Value, 0, mmap.Len())
 	values := make([]text.Value, 0, mmap.Len())
-	msgFields := fd.MessageType().Fields()
+	msgFields := fd.Message().Fields()
 	keyType := msgFields.ByNumber(1)
 	keyType := msgFields.ByNumber(1)
 	valType := msgFields.ByNumber(2)
 	valType := msgFields.ByNumber(2)
 
 
@@ -274,7 +274,7 @@ func (o MarshalOptions) appendExtensions(msgFields [][2]text.Value, knownFields
 		name := xt.FullName()
 		name := xt.FullName()
 		// If extended type is a MessageSet, set field name to be the message type name.
 		// If extended type is a MessageSet, set field name to be the message type name.
 		if isMessageSetExtension(xt) {
 		if isMessageSetExtension(xt) {
-			name = xt.MessageType().FullName()
+			name = xt.Message().FullName()
 		}
 		}
 
 
 		num := xt.Number()
 		num := xt.Number()
@@ -306,15 +306,15 @@ func isMessageSetExtension(xt pref.ExtensionType) bool {
 	if xt.Name() != "message_set_extension" {
 	if xt.Name() != "message_set_extension" {
 		return false
 		return false
 	}
 	}
-	mt := xt.MessageType()
-	if mt == nil {
+	md := xt.Message()
+	if md == nil {
 		return false
 		return false
 	}
 	}
-	if xt.FullName().Parent() != mt.FullName() {
+	if xt.FullName().Parent() != md.FullName() {
 		return false
 		return false
 	}
 	}
-	xmt, ok := xt.ExtendedType().(interface{ IsMessageSet() bool })
-	return ok && xmt.IsMessageSet()
+	xmd, ok := xt.Extendee().(interface{ IsMessageSet() bool })
+	return ok && xmd.IsMessageSet()
 }
 }
 
 
 // appendUnknown parses the given []byte and appends field(s) into the given fields slice.
 // appendUnknown parses the given []byte and appends field(s) into the given fields slice.

+ 2 - 2
internal/cmd/generate-protos/main.go

@@ -234,9 +234,9 @@ func generateFieldNumbers(gen *protogen.Plugin, file *protogen.File) {
 				typeName := fd.Kind().String()
 				typeName := fd.Kind().String()
 				switch fd.Kind() {
 				switch fd.Kind() {
 				case protoreflect.EnumKind:
 				case protoreflect.EnumKind:
-					typeName = string(fd.EnumType().FullName())
+					typeName = string(fd.Enum().FullName())
 				case protoreflect.MessageKind, protoreflect.GroupKind:
 				case protoreflect.MessageKind, protoreflect.GroupKind:
-					typeName = string(fd.MessageType().FullName())
+					typeName = string(fd.Message().FullName())
 				}
 				}
 				g.P(message.GoIdent.GoName, "_", field.GoName, "=", fd.Number(), "// ", fd.Cardinality(), " ", typeName)
 				g.P(message.GoIdent.GoName, "_", field.GoName, "=", fd.Number(), "// ", fd.Cardinality(), " ", typeName)
 			}
 			}

+ 1 - 1
internal/encoding/pack/pack.go

@@ -325,7 +325,7 @@ func (p *parser) parseMessage(msgDesc protoreflect.MessageDescriptor, group bool
 				kind = fieldDesc.Kind()
 				kind = fieldDesc.Kind()
 				switch kind {
 				switch kind {
 				case protoreflect.MessageKind, protoreflect.GroupKind:
 				case protoreflect.MessageKind, protoreflect.GroupKind:
-					subDesc = fieldDesc.MessageType()
+					subDesc = fieldDesc.Message()
 					if subDesc == nil || subDesc.IsPlaceholder() {
 					if subDesc == nil || subDesc.IsPlaceholder() {
 						kind = 0
 						kind = 0
 					}
 					}

+ 3 - 3
internal/encoding/tag/tag.go

@@ -166,7 +166,7 @@ func Marshal(fd pref.FieldDescriptor, enumName string) string {
 		// The name of the FieldDescriptor for a group field is
 		// The name of the FieldDescriptor for a group field is
 		// lowercased. To find the original capitalization, we
 		// lowercased. To find the original capitalization, we
 		// look in the field's MessageType.
 		// look in the field's MessageType.
-		name = string(fd.MessageType().Name())
+		name = string(fd.Message().Name())
 	}
 	}
 	tag = append(tag, "name="+name)
 	tag = append(tag, "name="+name)
 	if jsonName := fd.JSONName(); jsonName != "" && jsonName != name {
 	if jsonName := fd.JSONName(); jsonName != "" && jsonName != name {
@@ -175,13 +175,13 @@ func Marshal(fd pref.FieldDescriptor, enumName string) string {
 	// The previous implementation does not tag extension fields as proto3,
 	// The previous implementation does not tag extension fields as proto3,
 	// even when the field is defined in a proto3 file. Match that behavior
 	// even when the field is defined in a proto3 file. Match that behavior
 	// for consistency.
 	// for consistency.
-	if fd.Syntax() == pref.Proto3 && fd.ExtendedType() == nil {
+	if fd.Syntax() == pref.Proto3 && fd.Extendee() == nil {
 		tag = append(tag, "proto3")
 		tag = append(tag, "proto3")
 	}
 	}
 	if fd.Kind() == pref.EnumKind && enumName != "" {
 	if fd.Kind() == pref.EnumKind && enumName != "" {
 		tag = append(tag, "enum="+enumName)
 		tag = append(tag, "enum="+enumName)
 	}
 	}
-	if fd.OneofType() != nil {
+	if fd.Oneof() != nil {
 		tag = append(tag, "oneof")
 		tag = append(tag, "oneof")
 	}
 	}
 	// This must appear last in the tag, since commas in strings aren't escaped.
 	// This must appear last in the tag, since commas in strings aren't escaped.

+ 26 - 10
internal/fileinit/desc.go

@@ -439,13 +439,19 @@ func (fd *fieldDesc) IsMap() bool                                { return fd.isM
 func (fd *fieldDesc) HasDefault() bool                           { return fd.defVal.has }
 func (fd *fieldDesc) HasDefault() bool                           { return fd.defVal.has }
 func (fd *fieldDesc) Default() pref.Value                        { return fd.defVal.get() }
 func (fd *fieldDesc) Default() pref.Value                        { return fd.defVal.get() }
 func (fd *fieldDesc) DefaultEnumValue() pref.EnumValueDescriptor { return fd.defVal.enum }
 func (fd *fieldDesc) DefaultEnumValue() pref.EnumValueDescriptor { return fd.defVal.enum }
-func (fd *fieldDesc) OneofType() pref.OneofDescriptor            { return fd.oneofType }
-func (fd *fieldDesc) ExtendedType() pref.MessageDescriptor       { return nil }
-func (fd *fieldDesc) EnumType() pref.EnumDescriptor              { return fd.enumType }
-func (fd *fieldDesc) MessageType() pref.MessageDescriptor        { return fd.messageType }
+func (fd *fieldDesc) Oneof() pref.OneofDescriptor                { return fd.oneofType }
+func (fd *fieldDesc) Extendee() pref.MessageDescriptor           { return nil }
+func (fd *fieldDesc) Enum() pref.EnumDescriptor                  { return fd.enumType }
+func (fd *fieldDesc) Message() pref.MessageDescriptor            { return fd.messageType }
 func (fd *fieldDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, fd) }
 func (fd *fieldDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, fd) }
 func (fd *fieldDesc) ProtoType(pref.FieldDescriptor)             {}
 func (fd *fieldDesc) ProtoType(pref.FieldDescriptor)             {}
 
 
+// TODO: Remove these methods.
+func (fd *fieldDesc) OneofType() pref.OneofDescriptor      { return fd.Oneof() }
+func (fd *fieldDesc) ExtendedType() pref.MessageDescriptor { return fd.Extendee() }
+func (fd *fieldDesc) EnumType() pref.EnumDescriptor        { return fd.Enum() }
+func (fd *fieldDesc) MessageType() pref.MessageDescriptor  { return fd.Message() }
+
 func (od *oneofDesc) Options() pref.ProtoMessage {
 func (od *oneofDesc) Options() pref.ProtoMessage {
 	return unmarshalOptions(descopts.Oneof, od.options)
 	return unmarshalOptions(descopts.Oneof, od.options)
 }
 }
@@ -506,10 +512,10 @@ func (xd *extensionDesc) IsMap() bool                                { return fa
 func (xd *extensionDesc) HasDefault() bool                           { return xd.lazyInit().defVal.has }
 func (xd *extensionDesc) HasDefault() bool                           { return xd.lazyInit().defVal.has }
 func (xd *extensionDesc) Default() pref.Value                        { return xd.lazyInit().defVal.get() }
 func (xd *extensionDesc) Default() pref.Value                        { return xd.lazyInit().defVal.get() }
 func (xd *extensionDesc) DefaultEnumValue() pref.EnumValueDescriptor { return xd.lazyInit().defVal.enum }
 func (xd *extensionDesc) DefaultEnumValue() pref.EnumValueDescriptor { return xd.lazyInit().defVal.enum }
-func (xd *extensionDesc) OneofType() pref.OneofDescriptor            { return nil }
-func (xd *extensionDesc) ExtendedType() pref.MessageDescriptor       { return xd.extendedType }
-func (xd *extensionDesc) EnumType() pref.EnumDescriptor              { return xd.lazyInit().enumType }
-func (xd *extensionDesc) MessageType() pref.MessageDescriptor        { return xd.lazyInit().messageType }
+func (xd *extensionDesc) Oneof() pref.OneofDescriptor                { return nil }
+func (xd *extensionDesc) Extendee() pref.MessageDescriptor           { return xd.extendedType }
+func (xd *extensionDesc) Enum() pref.EnumDescriptor                  { return xd.lazyInit().enumType }
+func (xd *extensionDesc) Message() pref.MessageDescriptor            { return xd.lazyInit().messageType }
 func (xd *extensionDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, xd) }
 func (xd *extensionDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, xd) }
 func (xd *extensionDesc) ProtoType(pref.FieldDescriptor)             {}
 func (xd *extensionDesc) ProtoType(pref.FieldDescriptor)             {}
 func (xd *extensionDesc) ProtoInternal(pragma.DoNotImplement)        {}
 func (xd *extensionDesc) ProtoInternal(pragma.DoNotImplement)        {}
@@ -527,6 +533,12 @@ func (xd *extensionDesc) ProtoLegacyExtensionDesc() *piface.ExtensionDescV1 {
 	return xd.legacyDesc
 	return xd.legacyDesc
 }
 }
 
 
+// TODO: Remove these methods.
+func (xd *extensionDesc) OneofType() pref.OneofDescriptor      { return xd.Oneof() }
+func (xd *extensionDesc) ExtendedType() pref.MessageDescriptor { return xd.Extendee() }
+func (xd *extensionDesc) EnumType() pref.EnumDescriptor        { return xd.Enum() }
+func (xd *extensionDesc) MessageType() pref.MessageDescriptor  { return xd.Message() }
+
 type (
 type (
 	serviceDesc struct {
 	serviceDesc struct {
 		baseDesc
 		baseDesc
@@ -563,14 +575,18 @@ func (sd *serviceDesc) lazyInit() *serviceLazy {
 func (md *methodDesc) Options() pref.ProtoMessage {
 func (md *methodDesc) Options() pref.ProtoMessage {
 	return unmarshalOptions(descopts.Method, md.options)
 	return unmarshalOptions(descopts.Method, md.options)
 }
 }
-func (md *methodDesc) InputType() pref.MessageDescriptor   { return md.inputType }
-func (md *methodDesc) OutputType() pref.MessageDescriptor  { return md.outputType }
+func (md *methodDesc) Input() pref.MessageDescriptor       { return md.inputType }
+func (md *methodDesc) Output() pref.MessageDescriptor      { return md.outputType }
 func (md *methodDesc) IsStreamingClient() bool             { return md.isStreamingClient }
 func (md *methodDesc) IsStreamingClient() bool             { return md.isStreamingClient }
 func (md *methodDesc) IsStreamingServer() bool             { return md.isStreamingServer }
 func (md *methodDesc) IsStreamingServer() bool             { return md.isStreamingServer }
 func (md *methodDesc) Format(s fmt.State, r rune)          { pfmt.FormatDesc(s, r, md) }
 func (md *methodDesc) Format(s fmt.State, r rune)          { pfmt.FormatDesc(s, r, md) }
 func (md *methodDesc) ProtoType(pref.MethodDescriptor)     {}
 func (md *methodDesc) ProtoType(pref.MethodDescriptor)     {}
 func (md *methodDesc) ProtoInternal(pragma.DoNotImplement) {}
 func (md *methodDesc) ProtoInternal(pragma.DoNotImplement) {}
 
 
+// TODO: Remove these methods.
+func (md *methodDesc) InputType() pref.MessageDescriptor  { return md.Input() }
+func (md *methodDesc) OutputType() pref.MessageDescriptor { return md.Output() }
+
 type baseDesc struct {
 type baseDesc struct {
 	parentFile *fileDesc
 	parentFile *fileDesc
 	parent     pref.Descriptor
 	parent     pref.Descriptor

+ 1 - 1
internal/fileinit/fileinit_test.go

@@ -70,7 +70,7 @@ func TestInit(t *testing.T) {
 
 
 	// Verify that message descriptors for map entries have no Go type info.
 	// Verify that message descriptors for map entries have no Go type info.
 	mapEntryName := protoreflect.FullName("goproto.proto.test.TestAllTypes.MapInt32Int32Entry")
 	mapEntryName := protoreflect.FullName("goproto.proto.test.TestAllTypes.MapInt32Int32Entry")
-	d := testpb.File_test_test_proto.Messages().ByName("TestAllTypes").Fields().ByName("map_int32_int32").MessageType()
+	d := testpb.File_test_test_proto.Messages().ByName("TestAllTypes").Fields().ByName("map_int32_int32").Message()
 	if gotName, wantName := d.FullName(), mapEntryName; gotName != wantName {
 	if gotName, wantName := d.FullName(), mapEntryName; gotName != wantName {
 		t.Fatalf("looked up wrong descriptor: got %v, want %v", gotName, wantName)
 		t.Fatalf("looked up wrong descriptor: got %v, want %v", gotName, wantName)
 	}
 	}

+ 1 - 1
internal/impl/legacy_extension.go

@@ -149,7 +149,7 @@ func (p legacyExtensionTypes) Len() (n int) {
 }
 }
 
 
 func (p legacyExtensionTypes) Register(t pref.ExtensionType) {
 func (p legacyExtensionTypes) Register(t pref.ExtensionType) {
-	if p.mi.PBType.FullName() != t.ExtendedType().FullName() {
+	if p.mi.PBType.FullName() != t.Extendee().FullName() {
 		panic("extended type mismatch")
 		panic("extended type mismatch")
 	}
 	}
 	if !p.mi.PBType.ExtensionRanges().Has(t.Number()) {
 	if !p.mi.PBType.ExtensionRanges().Has(t.Number()) {

+ 7 - 1
internal/impl/legacy_test.go

@@ -769,7 +769,7 @@ func TestExtensionConvert(t *testing.T) {
 								// Ignore New since it a constructor.
 								// Ignore New since it a constructor.
 							case "Options":
 							case "Options":
 								// Ignore descriptor options since protos are not cmperable.
 								// Ignore descriptor options since protos are not cmperable.
-							case "EnumType", "MessageType", "ExtendedType":
+							case "Oneof", "Extendee", "Enum", "Message":
 								// Avoid descending into a dependency to avoid a cycle.
 								// Avoid descending into a dependency to avoid a cycle.
 								// Just record the full name if available.
 								// Just record the full name if available.
 								//
 								//
@@ -778,6 +778,12 @@ func TestExtensionConvert(t *testing.T) {
 								if !v.IsNil() {
 								if !v.IsNil() {
 									out[name] = v.Interface().(pref.Descriptor).FullName()
 									out[name] = v.Interface().(pref.Descriptor).FullName()
 								}
 								}
+							// TODO: Remove this when the methods are deleted.
+							case "OneofType", "ExtendedType", "EnumType", "MessageType":
+								v := m.Call(nil)[0]
+								if !v.IsNil() {
+									out[name] = v.Interface().(pref.Descriptor).FullName()
+								}
 							default:
 							default:
 								out[name] = m.Call(nil)[0].Interface()
 								out[name] = m.Call(nil)[0].Interface()
 							}
 							}

+ 2 - 2
internal/impl/message.go

@@ -115,8 +115,8 @@ fieldLoop:
 		switch {
 		switch {
 		case fd.IsWeak():
 		case fd.IsWeak():
 			fi = fieldInfoForWeak(fd, specialByName["XXX_weak"])
 			fi = fieldInfoForWeak(fd, specialByName["XXX_weak"])
-		case fd.OneofType() != nil:
-			fi = fieldInfoForOneof(fd, oneofsByName[fd.OneofType().Name()], oneofWrappersByNumber[fd.Number()])
+		case fd.Oneof() != nil:
+			fi = fieldInfoForOneof(fd, oneofsByName[fd.Oneof().Name()], oneofWrappersByNumber[fd.Number()])
 		case fd.IsMap():
 		case fd.IsMap():
 			fi = fieldInfoForMap(fd, fs)
 			fi = fieldInfoForMap(fd, fs)
 		case fd.Cardinality() == pref.Repeated:
 		case fd.Cardinality() == pref.Repeated:

+ 2 - 2
internal/impl/message_field.go

@@ -98,8 +98,8 @@ func fieldInfoForMap(fd pref.FieldDescriptor, fs reflect.StructField) fieldInfo
 	if ft.Kind() != reflect.Map {
 	if ft.Kind() != reflect.Map {
 		panic(fmt.Sprintf("invalid type: got %v, want map kind", ft))
 		panic(fmt.Sprintf("invalid type: got %v, want map kind", ft))
 	}
 	}
-	keyConv := pvalue.NewLegacyConverter(ft.Key(), fd.MessageType().Fields().ByNumber(1).Kind(), legacyWrapper)
-	valConv := pvalue.NewLegacyConverter(ft.Elem(), fd.MessageType().Fields().ByNumber(2).Kind(), legacyWrapper)
+	keyConv := pvalue.NewLegacyConverter(ft.Key(), fd.Message().Fields().ByNumber(1).Kind(), legacyWrapper)
+	valConv := pvalue.NewLegacyConverter(ft.Elem(), fd.Message().Fields().ByNumber(2).Kind(), legacyWrapper)
 	fieldOffset := offsetOf(fs)
 	fieldOffset := offsetOf(fs)
 	// TODO: Implement unsafe fast path?
 	// TODO: Implement unsafe fast path?
 	return fieldInfo{
 	return fieldInfo{

+ 2 - 2
internal/legacy/extension.go

@@ -64,7 +64,7 @@ func extensionDescFromType(t pref.ExtensionType) *piface.ExtensionDescV1 {
 
 
 	// Determine the parent type if possible.
 	// Determine the parent type if possible.
 	var parent piface.MessageV1
 	var parent piface.MessageV1
-	if mt, ok := t.ExtendedType().(pref.MessageType); ok {
+	if mt, ok := t.Extendee().(pref.MessageType); ok {
 		// Create a new parent message and unwrap it if possible.
 		// Create a new parent message and unwrap it if possible.
 		mv := mt.New().Interface()
 		mv := mt.New().Interface()
 		t := reflect.TypeOf(mv)
 		t := reflect.TypeOf(mv)
@@ -97,7 +97,7 @@ func extensionDescFromType(t pref.ExtensionType) *piface.ExtensionDescV1 {
 	if t.Kind() == pref.EnumKind {
 	if t.Kind() == pref.EnumKind {
 		// Derive Go type name.
 		// Derive Go type name.
 		// For legacy enums, unwrap the wrapper to get the underlying Go type.
 		// For legacy enums, unwrap the wrapper to get the underlying Go type.
-		et := t.EnumType().(pref.EnumType)
+		et := t.Enum().(pref.EnumType)
 		var ev interface{} = et.New(0)
 		var ev interface{} = et.New(0)
 		if u, ok := ev.(pvalue.Unwrapper); ok {
 		if u, ok := ev.(pvalue.Unwrapper); ok {
 			ev = u.ProtoUnwrap()
 			ev = u.ProtoUnwrap()

+ 7 - 1
internal/legacy/file_test.go

@@ -431,7 +431,7 @@ func TestDescriptor(t *testing.T) {
 					case "HasJSONName":
 					case "HasJSONName":
 						// Ignore this since the semantics of the field has
 						// Ignore this since the semantics of the field has
 						// changed across protoc and protoc-gen-go releases.
 						// changed across protoc and protoc-gen-go releases.
-					case "OneofType", "ExtendedType", "EnumType", "MessageType":
+					case "Oneof", "Extendee", "Enum", "Message":
 						// Avoid descending into a dependency to avoid a cycle.
 						// Avoid descending into a dependency to avoid a cycle.
 						// Just record the full name if available.
 						// Just record the full name if available.
 						//
 						//
@@ -440,6 +440,12 @@ func TestDescriptor(t *testing.T) {
 						if !v.IsNil() {
 						if !v.IsNil() {
 							out[name] = v.Interface().(pref.Descriptor).FullName()
 							out[name] = v.Interface().(pref.Descriptor).FullName()
 						}
 						}
+					// TODO: Remove this when the methods are deleted.
+					case "OneofType", "ExtendedType", "EnumType", "MessageType":
+						v := m.Call(nil)[0]
+						if !v.IsNil() {
+							out[name] = v.Interface().(pref.Descriptor).FullName()
+						}
 					default:
 					default:
 						out[name] = m.Call(nil)[0].Interface()
 						out[name] = m.Call(nil)[0].Interface()
 					}
 					}

+ 9 - 9
internal/legacy/legacy_test.go

@@ -55,24 +55,24 @@ func TestConcurrentInit(t *testing.T) {
 
 
 	var (
 	var (
 		wantMTA = messageATypes[0]
 		wantMTA = messageATypes[0]
-		wantMDA = messageATypes[0].Fields().ByNumber(1).MessageType()
+		wantMDA = messageATypes[0].Fields().ByNumber(1).Message()
 		wantMTB = messageBTypes[0]
 		wantMTB = messageBTypes[0]
-		wantMDB = messageBTypes[0].Fields().ByNumber(2).MessageType()
+		wantMDB = messageBTypes[0].Fields().ByNumber(2).Message()
 		wantET  = enumTypes[0]
 		wantET  = enumTypes[0]
-		wantED  = messageATypes[0].Fields().ByNumber(3).EnumType()
+		wantED  = messageATypes[0].Fields().ByNumber(3).Enum()
 	)
 	)
 
 
 	for _, gotMT := range messageATypes[1:] {
 	for _, gotMT := range messageATypes[1:] {
 		if gotMT != wantMTA {
 		if gotMT != wantMTA {
 			t.Error("MessageType(MessageA) mismatch")
 			t.Error("MessageType(MessageA) mismatch")
 		}
 		}
-		if gotMDA := gotMT.Fields().ByNumber(1).MessageType(); gotMDA != wantMDA {
+		if gotMDA := gotMT.Fields().ByNumber(1).Message(); gotMDA != wantMDA {
 			t.Error("MessageDescriptor(MessageA) mismatch")
 			t.Error("MessageDescriptor(MessageA) mismatch")
 		}
 		}
-		if gotMDB := gotMT.Fields().ByNumber(2).MessageType(); gotMDB != wantMDB {
+		if gotMDB := gotMT.Fields().ByNumber(2).Message(); gotMDB != wantMDB {
 			t.Error("MessageDescriptor(MessageB) mismatch")
 			t.Error("MessageDescriptor(MessageB) mismatch")
 		}
 		}
-		if gotED := gotMT.Fields().ByNumber(3).EnumType(); gotED != wantED {
+		if gotED := gotMT.Fields().ByNumber(3).Enum(); gotED != wantED {
 			t.Error("EnumDescriptor(Enum) mismatch")
 			t.Error("EnumDescriptor(Enum) mismatch")
 		}
 		}
 	}
 	}
@@ -80,13 +80,13 @@ func TestConcurrentInit(t *testing.T) {
 		if gotMT != wantMTB {
 		if gotMT != wantMTB {
 			t.Error("MessageType(MessageB) mismatch")
 			t.Error("MessageType(MessageB) mismatch")
 		}
 		}
-		if gotMDA := gotMT.Fields().ByNumber(1).MessageType(); gotMDA != wantMDA {
+		if gotMDA := gotMT.Fields().ByNumber(1).Message(); gotMDA != wantMDA {
 			t.Error("MessageDescriptor(MessageA) mismatch")
 			t.Error("MessageDescriptor(MessageA) mismatch")
 		}
 		}
-		if gotMDB := gotMT.Fields().ByNumber(2).MessageType(); gotMDB != wantMDB {
+		if gotMDB := gotMT.Fields().ByNumber(2).Message(); gotMDB != wantMDB {
 			t.Error("MessageDescriptor(MessageB) mismatch")
 			t.Error("MessageDescriptor(MessageB) mismatch")
 		}
 		}
-		if gotED := gotMT.Fields().ByNumber(3).EnumType(); gotED != wantED {
+		if gotED := gotMT.Fields().ByNumber(3).Enum(); gotED != wantED {
 			t.Error("EnumDescriptor(Enum) mismatch")
 			t.Error("EnumDescriptor(Enum) mismatch")
 		}
 		}
 	}
 	}

+ 3 - 3
internal/prototype/go_type.go

@@ -118,12 +118,12 @@ func (t *goMessage) Format(s fmt.State, r rune) {
 // The type M is the concrete message type returned by NewMessage,
 // The type M is the concrete message type returned by NewMessage,
 // which is often, but not required to be, a pointer to a named struct type.
 // which is often, but not required to be, a pointer to a named struct type.
 func GoExtension(xd protoreflect.ExtensionDescriptor, et protoreflect.EnumType, mt protoreflect.MessageType) protoreflect.ExtensionType {
 func GoExtension(xd protoreflect.ExtensionDescriptor, et protoreflect.EnumType, mt protoreflect.MessageType) protoreflect.ExtensionType {
-	if xd.ExtendedType() == nil {
+	if xd.Extendee() == nil {
 		panic("field descriptor does not extend a message")
 		panic("field descriptor does not extend a message")
 	}
 	}
 	switch xd.Kind() {
 	switch xd.Kind() {
 	case protoreflect.EnumKind:
 	case protoreflect.EnumKind:
-		if et2, ok := xd.EnumType().(protoreflect.EnumType); ok && et == nil {
+		if et2, ok := xd.Enum().(protoreflect.EnumType); ok && et == nil {
 			et = et2
 			et = et2
 		}
 		}
 		if et == nil {
 		if et == nil {
@@ -133,7 +133,7 @@ func GoExtension(xd protoreflect.ExtensionDescriptor, et protoreflect.EnumType,
 			panic("message type provided for enum kind")
 			panic("message type provided for enum kind")
 		}
 		}
 	case protoreflect.MessageKind, protoreflect.GroupKind:
 	case protoreflect.MessageKind, protoreflect.GroupKind:
-		if mt2, ok := xd.MessageType().(protoreflect.MessageType); ok && mt == nil {
+		if mt2, ok := xd.Message().(protoreflect.MessageType); ok && mt == nil {
 			mt = mt2
 			mt = mt2
 		}
 		}
 		if et != nil {
 		if et != nil {

+ 4 - 4
internal/prototype/protofile_list.go

@@ -101,11 +101,11 @@ type oneofFields oneofFieldsMeta
 
 
 func (p *oneofFieldsMeta) lazyInit(parent pref.Descriptor) *oneofFields {
 func (p *oneofFieldsMeta) lazyInit(parent pref.Descriptor) *oneofFields {
 	p.once.Do(func() {
 	p.once.Do(func() {
-		otyp := parent.(pref.OneofDescriptor)
-		mtyp, _ := parent.Parent()
-		fs := mtyp.(pref.MessageDescriptor).Fields()
+		od := parent.(pref.OneofDescriptor)
+		md, _ := parent.Parent()
+		fs := md.(pref.MessageDescriptor).Fields()
 		for i := 0; i < fs.Len(); i++ {
 		for i := 0; i < fs.Len(); i++ {
-			if f := fs.Get(i); otyp == f.OneofType() {
+			if f := fs.Get(i); od == f.Oneof() {
 				p.typs = append(p.typs, f)
 				p.typs = append(p.typs, f)
 			}
 			}
 		}
 		}

+ 34 - 22
internal/prototype/protofile_type.go

@@ -160,20 +160,26 @@ func (t fieldDesc) IsPacked() bool {
 }
 }
 func (t fieldDesc) IsWeak() bool { return t.f.IsWeak }
 func (t fieldDesc) IsWeak() bool { return t.f.IsWeak }
 func (t fieldDesc) IsMap() bool {
 func (t fieldDesc) IsMap() bool {
-	mt := t.MessageType()
+	mt := t.Message()
 	return mt != nil && mt.IsMapEntry()
 	return mt != nil && mt.IsMapEntry()
 }
 }
 func (t fieldDesc) HasDefault() bool                           { return t.f.Default.IsValid() }
 func (t fieldDesc) HasDefault() bool                           { return t.f.Default.IsValid() }
 func (t fieldDesc) Default() pref.Value                        { return t.f.dv.value(t, t.f.Default) }
 func (t fieldDesc) Default() pref.Value                        { return t.f.dv.value(t, t.f.Default) }
 func (t fieldDesc) DefaultEnumValue() pref.EnumValueDescriptor { return t.f.dv.enum(t, t.f.Default) }
 func (t fieldDesc) DefaultEnumValue() pref.EnumValueDescriptor { return t.f.dv.enum(t, t.f.Default) }
-func (t fieldDesc) OneofType() pref.OneofDescriptor            { return t.f.ot.lazyInit(t, t.f.OneofName) }
-func (t fieldDesc) ExtendedType() pref.MessageDescriptor       { return nil }
-func (t fieldDesc) MessageType() pref.MessageDescriptor        { return t.f.mt.lazyInit(t, &t.f.MessageType) }
-func (t fieldDesc) EnumType() pref.EnumDescriptor              { return t.f.et.lazyInit(t, &t.f.EnumType) }
+func (t fieldDesc) Oneof() pref.OneofDescriptor                { return t.f.ot.lazyInit(t, t.f.OneofName) }
+func (t fieldDesc) Extendee() pref.MessageDescriptor           { return nil }
+func (t fieldDesc) Enum() pref.EnumDescriptor                  { return t.f.et.lazyInit(t, &t.f.EnumType) }
+func (t fieldDesc) Message() pref.MessageDescriptor            { return t.f.mt.lazyInit(t, &t.f.MessageType) }
 func (t fieldDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, t) }
 func (t fieldDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, t) }
 func (t fieldDesc) ProtoType(pref.FieldDescriptor)             {}
 func (t fieldDesc) ProtoType(pref.FieldDescriptor)             {}
 func (t fieldDesc) ProtoInternal(pragma.DoNotImplement)        {}
 func (t fieldDesc) ProtoInternal(pragma.DoNotImplement)        {}
 
 
+// TODO: Remove these methods.
+func (t fieldDesc) OneofType() pref.OneofDescriptor      { return t.Oneof() }
+func (t fieldDesc) ExtendedType() pref.MessageDescriptor { return t.Extendee() }
+func (t fieldDesc) EnumType() pref.EnumDescriptor        { return t.Enum() }
+func (t fieldDesc) MessageType() pref.MessageDescriptor  { return t.Message() }
+
 func isPacked(packed OptionalBool, s pref.Syntax, c pref.Cardinality, k pref.Kind) bool {
 func isPacked(packed OptionalBool, s pref.Syntax, c pref.Cardinality, k pref.Kind) bool {
 	if packed == False || (packed == DefaultBool && s == pref.Proto2) {
 	if packed == False || (packed == DefaultBool && s == pref.Proto2) {
 		return false
 		return false
@@ -289,17 +295,19 @@ func (t extensionDesc) IsMap() bool                                { return fals
 func (t extensionDesc) HasDefault() bool                           { return t.x.Default.IsValid() }
 func (t extensionDesc) HasDefault() bool                           { return t.x.Default.IsValid() }
 func (t extensionDesc) Default() pref.Value                        { return t.x.dv.value(t, t.x.Default) }
 func (t extensionDesc) Default() pref.Value                        { return t.x.dv.value(t, t.x.Default) }
 func (t extensionDesc) DefaultEnumValue() pref.EnumValueDescriptor { return t.x.dv.enum(t, t.x.Default) }
 func (t extensionDesc) DefaultEnumValue() pref.EnumValueDescriptor { return t.x.dv.enum(t, t.x.Default) }
-func (t extensionDesc) OneofType() pref.OneofDescriptor            { return nil }
-func (t extensionDesc) ExtendedType() pref.MessageDescriptor {
-	return t.x.xt.lazyInit(t, &t.x.ExtendedType)
-}
-func (t extensionDesc) MessageType() pref.MessageDescriptor {
-	return t.x.mt.lazyInit(t, &t.x.MessageType)
-}
-func (t extensionDesc) EnumType() pref.EnumDescriptor       { return t.x.et.lazyInit(t, &t.x.EnumType) }
-func (t extensionDesc) Format(s fmt.State, r rune)          { pfmt.FormatDesc(s, r, t) }
-func (t extensionDesc) ProtoType(pref.FieldDescriptor)      {}
-func (t extensionDesc) ProtoInternal(pragma.DoNotImplement) {}
+func (t extensionDesc) Oneof() pref.OneofDescriptor                { return nil }
+func (t extensionDesc) Extendee() pref.MessageDescriptor           { return t.x.xt.lazyInit(t, &t.x.ExtendedType) }
+func (t extensionDesc) Enum() pref.EnumDescriptor                  { return t.x.et.lazyInit(t, &t.x.EnumType) }
+func (t extensionDesc) Message() pref.MessageDescriptor            { return t.x.mt.lazyInit(t, &t.x.MessageType) }
+func (t extensionDesc) Format(s fmt.State, r rune)                 { pfmt.FormatDesc(s, r, t) }
+func (t extensionDesc) ProtoType(pref.FieldDescriptor)             {}
+func (t extensionDesc) ProtoInternal(pragma.DoNotImplement)        {}
+
+// TODO: Remove these methods.
+func (t extensionDesc) OneofType() pref.OneofDescriptor      { return t.Oneof() }
+func (t extensionDesc) ExtendedType() pref.MessageDescriptor { return t.Extendee() }
+func (t extensionDesc) EnumType() pref.EnumDescriptor        { return t.Enum() }
+func (t extensionDesc) MessageType() pref.MessageDescriptor  { return t.Message() }
 
 
 type enumMeta struct {
 type enumMeta struct {
 	inheritedMeta
 	inheritedMeta
@@ -377,14 +385,18 @@ func (t methodDesc) Name() pref.Name                     { return t.m.Name }
 func (t methodDesc) FullName() pref.FullName             { return t.m.fullName }
 func (t methodDesc) FullName() pref.FullName             { return t.m.fullName }
 func (t methodDesc) IsPlaceholder() bool                 { return false }
 func (t methodDesc) IsPlaceholder() bool                 { return false }
 func (t methodDesc) Options() pref.ProtoMessage          { return altOptions(t.m.Options, descopts.Method) }
 func (t methodDesc) Options() pref.ProtoMessage          { return altOptions(t.m.Options, descopts.Method) }
-func (t methodDesc) InputType() pref.MessageDescriptor   { return t.m.mit.lazyInit(t, &t.m.InputType) }
-func (t methodDesc) OutputType() pref.MessageDescriptor  { return t.m.mot.lazyInit(t, &t.m.OutputType) }
+func (t methodDesc) Input() pref.MessageDescriptor       { return t.m.mit.lazyInit(t, &t.m.InputType) }
+func (t methodDesc) Output() pref.MessageDescriptor      { return t.m.mot.lazyInit(t, &t.m.OutputType) }
 func (t methodDesc) IsStreamingClient() bool             { return t.m.IsStreamingClient }
 func (t methodDesc) IsStreamingClient() bool             { return t.m.IsStreamingClient }
 func (t methodDesc) IsStreamingServer() bool             { return t.m.IsStreamingServer }
 func (t methodDesc) IsStreamingServer() bool             { return t.m.IsStreamingServer }
 func (t methodDesc) Format(s fmt.State, r rune)          { pfmt.FormatDesc(s, r, t) }
 func (t methodDesc) Format(s fmt.State, r rune)          { pfmt.FormatDesc(s, r, t) }
 func (t methodDesc) ProtoType(pref.MethodDescriptor)     {}
 func (t methodDesc) ProtoType(pref.MethodDescriptor)     {}
 func (t methodDesc) ProtoInternal(pragma.DoNotImplement) {}
 func (t methodDesc) ProtoInternal(pragma.DoNotImplement) {}
 
 
+// TODO: Remove these methods.
+func (t methodDesc) InputType() pref.MessageDescriptor  { return t.Input() }
+func (t methodDesc) OutputType() pref.MessageDescriptor { return t.Output() }
+
 type defaultValue struct {
 type defaultValue struct {
 	once sync.Once
 	once sync.Once
 	val  pref.Value
 	val  pref.Value
@@ -417,12 +429,12 @@ func (p *defaultValue) lazyInit(t pref.FieldDescriptor, v pref.Value) {
 				// default value for an enum value is the wrong type.
 				// default value for an enum value is the wrong type.
 				switch v := v.Interface().(type) {
 				switch v := v.Interface().(type) {
 				case string:
 				case string:
-					if ev := t.EnumType().Values().ByName(pref.Name(v)); ev != nil {
+					if ev := t.Enum().Values().ByName(pref.Name(v)); ev != nil {
 						p.eval = ev
 						p.eval = ev
 						p.val = pref.ValueOf(p.eval.Number())
 						p.val = pref.ValueOf(p.eval.Number())
 					}
 					}
 				case pref.EnumNumber:
 				case pref.EnumNumber:
-					p.eval = t.EnumType().Values().ByNumber(v)
+					p.eval = t.Enum().Values().ByNumber(v)
 				}
 				}
 			case pref.BytesKind:
 			case pref.BytesKind:
 				// Store a copy of the default bytes, so that we can detect
 				// Store a copy of the default bytes, so that we can detect
@@ -455,8 +467,8 @@ func (p *defaultValue) lazyInit(t pref.FieldDescriptor, v pref.Value) {
 		case pref.EnumKind:
 		case pref.EnumKind:
 			p.val = zeroEnum
 			p.val = zeroEnum
 			if t.Syntax() == pref.Proto2 {
 			if t.Syntax() == pref.Proto2 {
-				if et := t.EnumType(); et != nil {
-					if vs := et.Values(); vs.Len() > 0 {
+				if ed := t.Enum(); ed != nil {
+					if vs := ed.Values(); vs.Len() > 0 {
 						p.val = pref.ValueOf(vs.Get(0).Number())
 						p.val = pref.ValueOf(vs.Get(0).Number())
 					}
 					}
 				}
 				}

+ 13 - 7
internal/prototype/standalone_type.go

@@ -89,10 +89,16 @@ func (t standaloneExtension) Default() pref.Value { return t.x.dv.value(t, t.x.D
 func (t standaloneExtension) DefaultEnumValue() pref.EnumValueDescriptor {
 func (t standaloneExtension) DefaultEnumValue() pref.EnumValueDescriptor {
 	return t.x.dv.enum(t, t.x.Default)
 	return t.x.dv.enum(t, t.x.Default)
 }
 }
-func (t standaloneExtension) OneofType() pref.OneofDescriptor      { return nil }
-func (t standaloneExtension) MessageType() pref.MessageDescriptor  { return t.x.MessageType }
-func (t standaloneExtension) EnumType() pref.EnumDescriptor        { return t.x.EnumType }
-func (t standaloneExtension) ExtendedType() pref.MessageDescriptor { return t.x.ExtendedType }
-func (t standaloneExtension) Format(s fmt.State, r rune)           { pfmt.FormatDesc(s, r, t) }
-func (t standaloneExtension) ProtoType(pref.FieldDescriptor)       {}
-func (t standaloneExtension) ProtoInternal(pragma.DoNotImplement)  {}
+func (t standaloneExtension) Oneof() pref.OneofDescriptor         { return nil }
+func (t standaloneExtension) Extendee() pref.MessageDescriptor    { return t.x.ExtendedType }
+func (t standaloneExtension) Enum() pref.EnumDescriptor           { return t.x.EnumType }
+func (t standaloneExtension) Message() pref.MessageDescriptor     { return t.x.MessageType }
+func (t standaloneExtension) Format(s fmt.State, r rune)          { pfmt.FormatDesc(s, r, t) }
+func (t standaloneExtension) ProtoType(pref.FieldDescriptor)      {}
+func (t standaloneExtension) ProtoInternal(pragma.DoNotImplement) {}
+
+// TODO: Remove these methods.
+func (t standaloneExtension) OneofType() pref.OneofDescriptor      { return t.Oneof() }
+func (t standaloneExtension) ExtendedType() pref.MessageDescriptor { return t.Extendee() }
+func (t standaloneExtension) EnumType() pref.EnumDescriptor        { return t.Enum() }
+func (t standaloneExtension) MessageType() pref.MessageDescriptor  { return t.Message() }

+ 76 - 76
internal/prototype/type_test.go

@@ -391,42 +391,42 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 				"Fields": M{
 				"Fields": M{
 					"Len": 2,
 					"Len": 2,
 					"ByNumber:1": M{
 					"ByNumber:1": M{
-						"Parent":       M{"FullName": pref.FullName("test.A")},
-						"Index":        0,
-						"Name":         pref.Name("key"),
-						"FullName":     pref.FullName("test.A.key"),
-						"Number":       pref.FieldNumber(1),
-						"Cardinality":  pref.Optional,
-						"Kind":         pref.StringKind,
-						"Options":      &descriptorpb.FieldOptions{Deprecated: scalar.Bool(true)},
-						"HasJSONName":  false,
-						"JSONName":     "key",
-						"IsPacked":     false,
-						"IsMap":        false,
-						"IsWeak":       false,
-						"Default":      "",
-						"OneofType":    nil,
-						"ExtendedType": nil,
-						"MessageType":  nil,
-						"EnumType":     nil,
+						"Parent":      M{"FullName": pref.FullName("test.A")},
+						"Index":       0,
+						"Name":        pref.Name("key"),
+						"FullName":    pref.FullName("test.A.key"),
+						"Number":      pref.FieldNumber(1),
+						"Cardinality": pref.Optional,
+						"Kind":        pref.StringKind,
+						"Options":     &descriptorpb.FieldOptions{Deprecated: scalar.Bool(true)},
+						"HasJSONName": false,
+						"JSONName":    "key",
+						"IsPacked":    false,
+						"IsMap":       false,
+						"IsWeak":      false,
+						"Default":     "",
+						"Oneof":       nil,
+						"Extendee":    nil,
+						"Message":     nil,
+						"Enum":        nil,
 					},
 					},
 					"ByNumber:2": M{
 					"ByNumber:2": M{
-						"Parent":       M{"FullName": pref.FullName("test.A")},
-						"Index":        1,
-						"Name":         pref.Name("value"),
-						"FullName":     pref.FullName("test.A.value"),
-						"Number":       pref.FieldNumber(2),
-						"Cardinality":  pref.Optional,
-						"Kind":         pref.MessageKind,
-						"JSONName":     "value",
-						"IsPacked":     false,
-						"IsMap":        false,
-						"IsWeak":       false,
-						"Default":      nil,
-						"OneofType":    nil,
-						"ExtendedType": nil,
-						"MessageType":  M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
-						"EnumType":     nil,
+						"Parent":      M{"FullName": pref.FullName("test.A")},
+						"Index":       1,
+						"Name":        pref.Name("value"),
+						"FullName":    pref.FullName("test.A.value"),
+						"Number":      pref.FieldNumber(2),
+						"Cardinality": pref.Optional,
+						"Kind":        pref.MessageKind,
+						"JSONName":    "value",
+						"IsPacked":    false,
+						"IsMap":       false,
+						"IsWeak":      false,
+						"Default":     nil,
+						"Oneof":       nil,
+						"Extendee":    nil,
+						"Message":     M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
+						"Enum":        nil,
 					},
 					},
 					"ByNumber:3": nil,
 					"ByNumber:3": nil,
 				},
 				},
@@ -444,11 +444,11 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 					"Len":                  6,
 					"Len":                  6,
 					"ByJSONName:field_one": nil,
 					"ByJSONName:field_one": nil,
 					"ByJSONName:fieldOne": M{
 					"ByJSONName:fieldOne": M{
-						"Name":      pref.Name("field_one"),
-						"Index":     0,
-						"JSONName":  "fieldOne",
-						"Default":   "hello, \"world!\"\n",
-						"OneofType": M{"Name": pref.Name("O1"), "IsPlaceholder": false},
+						"Name":     pref.Name("field_one"),
+						"Index":    0,
+						"JSONName": "fieldOne",
+						"Default":  "hello, \"world!\"\n",
+						"Oneof":    M{"Name": pref.Name("O1"), "IsPlaceholder": false},
 					},
 					},
 					"ByJSONName:fieldTwo": nil,
 					"ByJSONName:fieldTwo": nil,
 					"ByJSONName:Field2": M{
 					"ByJSONName:Field2": M{
@@ -457,20 +457,20 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 						"HasJSONName": true,
 						"HasJSONName": true,
 						"JSONName":    "Field2",
 						"JSONName":    "Field2",
 						"Default":     pref.EnumNumber(1),
 						"Default":     pref.EnumNumber(1),
-						"OneofType":   M{"Name": pref.Name("O2"), "IsPlaceholder": false},
+						"Oneof":       M{"Name": pref.Name("O2"), "IsPlaceholder": false},
 					},
 					},
 					"ByName:fieldThree": nil,
 					"ByName:fieldThree": nil,
 					"ByName:field_three": M{
 					"ByName:field_three": M{
-						"IsMap":       false,
-						"MessageType": M{"FullName": pref.FullName("test.C"), "IsPlaceholder": false},
-						"OneofType":   M{"Name": pref.Name("O2"), "IsPlaceholder": false},
+						"IsMap":   false,
+						"Message": M{"FullName": pref.FullName("test.C"), "IsPlaceholder": false},
+						"Oneof":   M{"Name": pref.Name("O2"), "IsPlaceholder": false},
 					},
 					},
 					"ByNumber:12": nil,
 					"ByNumber:12": nil,
 					"ByNumber:4": M{
 					"ByNumber:4": M{
 						"Cardinality": pref.Repeated,
 						"Cardinality": pref.Repeated,
 						"IsMap":       true,
 						"IsMap":       true,
 						"Default":     nil,
 						"Default":     nil,
-						"MessageType": M{"FullName": pref.FullName("test.A"), "IsPlaceholder": false},
+						"Message":     M{"FullName": pref.FullName("test.A"), "IsPlaceholder": false},
 					},
 					},
 					"ByNumber:5": M{
 					"ByNumber:5": M{
 						"Cardinality": pref.Repeated,
 						"Cardinality": pref.Repeated,
@@ -481,7 +481,7 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 					"ByNumber:6": M{
 					"ByNumber:6": M{
 						"Cardinality": pref.Required,
 						"Cardinality": pref.Required,
 						"Default":     []byte(nil),
 						"Default":     []byte(nil),
-						"OneofType":   nil,
+						"Oneof":       nil,
 					},
 					},
 				},
 				},
 				"Oneofs": M{
 				"Oneofs": M{
@@ -601,14 +601,14 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 		"Extensions": M{
 		"Extensions": M{
 			"Len": 1,
 			"Len": 1,
 			"ByName:X": M{
 			"ByName:X": M{
-				"Name":         pref.Name("X"),
-				"Number":       pref.FieldNumber(1000),
-				"Cardinality":  pref.Repeated,
-				"Kind":         pref.MessageKind,
-				"IsPacked":     false,
-				"MessageType":  M{"FullName": pref.FullName("test.C"), "IsPlaceholder": false},
-				"ExtendedType": M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
-				"Options":      &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
+				"Name":        pref.Name("X"),
+				"Number":      pref.FieldNumber(1000),
+				"Cardinality": pref.Repeated,
+				"Kind":        pref.MessageKind,
+				"IsPacked":    false,
+				"Message":     M{"FullName": pref.FullName("test.C"), "IsPlaceholder": false},
+				"Extendee":    M{"FullName": pref.FullName("test.B"), "IsPlaceholder": false},
+				"Options":     &descriptorpb.FieldOptions{Packed: scalar.Bool(true)},
 			},
 			},
 		},
 		},
 		"Services": M{
 		"Services": M{
@@ -625,8 +625,8 @@ func testFileAccessors(t *testing.T, fd pref.FileDescriptor) {
 						"Parent":            M{"FullName": pref.FullName("test.S")},
 						"Parent":            M{"FullName": pref.FullName("test.S")},
 						"Name":              pref.Name("M"),
 						"Name":              pref.Name("M"),
 						"FullName":          pref.FullName("test.S.M"),
 						"FullName":          pref.FullName("test.S.M"),
-						"InputType":         M{"FullName": pref.FullName("test.A"), "IsPlaceholder": false},
-						"OutputType":        M{"FullName": pref.FullName("test.C.A"), "IsPlaceholder": false},
+						"Input":             M{"FullName": pref.FullName("test.A"), "IsPlaceholder": false},
+						"Output":            M{"FullName": pref.FullName("test.C.A"), "IsPlaceholder": false},
 						"IsStreamingClient": true,
 						"IsStreamingClient": true,
 						"IsStreamingServer": true,
 						"IsStreamingServer": true,
 						"Options":           &descriptorpb.MethodOptions{Deprecated: scalar.Bool(true)},
 						"Options":           &descriptorpb.MethodOptions{Deprecated: scalar.Bool(true)},
@@ -728,7 +728,7 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) {
 			Cardinality: optional
 			Cardinality: optional
 			Kind:        message
 			Kind:        message
 			JSONName:    "value"
 			JSONName:    "value"
-			MessageType: test.B
+			Message:     test.B
 		}]
 		}]
 	}, {
 	}, {
 		Name: B
 		Name: B
@@ -740,7 +740,7 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) {
 			JSONName:    "fieldOne"
 			JSONName:    "fieldOne"
 			HasDefault:  true
 			HasDefault:  true
 			Default:     "hello, \"world!\"\n"
 			Default:     "hello, \"world!\"\n"
-			OneofType:   O1
+			Oneof:       O1
 		}, {
 		}, {
 			Name:        field_two
 			Name:        field_two
 			Number:      2
 			Number:      2
@@ -750,16 +750,16 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) {
 			JSONName:    "Field2"
 			JSONName:    "Field2"
 			HasDefault:  true
 			HasDefault:  true
 			Default:     1
 			Default:     1
-			OneofType:   O2
-			EnumType:    test.E1
+			Oneof:       O2
+			Enum:        test.E1
 		}, {
 		}, {
 			Name:        field_three
 			Name:        field_three
 			Number:      3
 			Number:      3
 			Cardinality: optional
 			Cardinality: optional
 			Kind:        message
 			Kind:        message
 			JSONName:    "fieldThree"
 			JSONName:    "fieldThree"
-			OneofType:   O2
-			MessageType: test.C
+			Oneof:       O2
+			Message:     test.C
 		}, {
 		}, {
 			Name:        field_four
 			Name:        field_four
 			Number:      4
 			Number:      4
@@ -768,7 +768,7 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) {
 			HasJSONName: true
 			HasJSONName: true
 			JSONName:    "Field4"
 			JSONName:    "Field4"
 			IsMap:       true
 			IsMap:       true
-			MessageType: test.A
+			Message:     test.A
 		}, {
 		}, {
 			Name:        field_five
 			Name:        field_five
 			Number:      5
 			Number:      5
@@ -817,12 +817,12 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) {
 			]
 			]
 		}]
 		}]
 		Extensions: [{
 		Extensions: [{
-			Name:         X
-			Number:       1000
-			Cardinality:  repeated
-			Kind:         message
-			ExtendedType: test.B
-			MessageType:  test.C
+			Name:        X
+			Number:      1000
+			Cardinality: repeated
+			Kind:        message
+			Extendee:    test.B
+			Message:     test.C
 		}]
 		}]
 	}]
 	}]
 	Enums: [{
 	Enums: [{
@@ -835,19 +835,19 @@ func testFileFormat(t *testing.T, fd pref.FileDescriptor) {
 		ReservedRanges: [10:20, 30]
 		ReservedRanges: [10:20, 30]
 	}]
 	}]
 	Extensions: [{
 	Extensions: [{
-		Name:         X
-		Number:       1000
-		Cardinality:  repeated
-		Kind:         message
-		ExtendedType: test.B
-		MessageType:  test.C
+		Name:        X
+		Number:      1000
+		Cardinality: repeated
+		Kind:        message
+		Extendee:    test.B
+		Message:     test.C
 	}]
 	}]
 	Services: [{
 	Services: [{
 		Name: S
 		Name: S
 		Methods: [{
 		Methods: [{
 			Name:              M
 			Name:              M
-			InputType:         test.A
-			OutputType:        test.C.A
+			Input:             test.A
+			Output:            test.C.A
 			IsStreamingClient: true
 			IsStreamingClient: true
 			IsStreamingServer: true
 			IsStreamingServer: true
 		}]
 		}]

+ 8 - 0
internal/typefmt/desc_test.go

@@ -27,6 +27,14 @@ func TestDescriptorAccessors(t *testing.T) {
 		"DescriptorProto":       true,
 		"DescriptorProto":       true,
 		"ExtensionRangeOptions": true,
 		"ExtensionRangeOptions": true,
 		"Options":               true,
 		"Options":               true,
+
+		// TODO: Remove these when the methods are removed.
+		"OneofType":    true,
+		"ExtendedType": true,
+		"EnumType":     true,
+		"MessageType":  true,
+		"InputType":    true,
+		"OutputType":   true,
 	}
 	}
 
 
 	for rt, m := range descriptorAccessors {
 	for rt, m := range descriptorAccessors {

+ 2 - 2
internal/typefmt/stringer.go

@@ -106,12 +106,12 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
 var descriptorAccessors = map[reflect.Type][]string{
 var descriptorAccessors = map[reflect.Type][]string{
 	reflect.TypeOf((*pref.FileDescriptor)(nil)).Elem():      {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"},
 	reflect.TypeOf((*pref.FileDescriptor)(nil)).Elem():      {"Path", "Package", "Imports", "Messages", "Enums", "Extensions", "Services"},
 	reflect.TypeOf((*pref.MessageDescriptor)(nil)).Elem():   {"IsMapEntry", "Fields", "Oneofs", "ReservedNames", "ReservedRanges", "RequiredNumbers", "ExtensionRanges", "Messages", "Enums", "Extensions"},
 	reflect.TypeOf((*pref.MessageDescriptor)(nil)).Elem():   {"IsMapEntry", "Fields", "Oneofs", "ReservedNames", "ReservedRanges", "RequiredNumbers", "ExtensionRanges", "Messages", "Enums", "Extensions"},
-	reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem():     {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "IsPacked", "IsMap", "IsWeak", "HasDefault", "Default", "OneofType", "ExtendedType", "MessageType", "EnumType"},
+	reflect.TypeOf((*pref.FieldDescriptor)(nil)).Elem():     {"Number", "Cardinality", "Kind", "HasJSONName", "JSONName", "IsPacked", "IsMap", "IsWeak", "HasDefault", "Default", "Oneof", "Extendee", "Message", "Enum"},
 	reflect.TypeOf((*pref.OneofDescriptor)(nil)).Elem():     {"Fields"}, // not directly used; must keep in sync with formatDescOpt
 	reflect.TypeOf((*pref.OneofDescriptor)(nil)).Elem():     {"Fields"}, // not directly used; must keep in sync with formatDescOpt
 	reflect.TypeOf((*pref.EnumDescriptor)(nil)).Elem():      {"Values", "ReservedNames", "ReservedRanges"},
 	reflect.TypeOf((*pref.EnumDescriptor)(nil)).Elem():      {"Values", "ReservedNames", "ReservedRanges"},
 	reflect.TypeOf((*pref.EnumValueDescriptor)(nil)).Elem(): {"Number"},
 	reflect.TypeOf((*pref.EnumValueDescriptor)(nil)).Elem(): {"Number"},
 	reflect.TypeOf((*pref.ServiceDescriptor)(nil)).Elem():   {"Methods"},
 	reflect.TypeOf((*pref.ServiceDescriptor)(nil)).Elem():   {"Methods"},
-	reflect.TypeOf((*pref.MethodDescriptor)(nil)).Elem():    {"InputType", "OutputType", "IsStreamingClient", "IsStreamingServer"},
+	reflect.TypeOf((*pref.MethodDescriptor)(nil)).Elem():    {"Input", "Output", "IsStreamingClient", "IsStreamingServer"},
 }
 }
 
 
 func FormatDesc(s fmt.State, r rune, t pref.Descriptor) {
 func FormatDesc(s fmt.State, r rune, t pref.Descriptor) {

+ 3 - 3
proto/decode.go

@@ -118,7 +118,7 @@ func (o UnmarshalOptions) unmarshalScalarField(b []byte, wtyp wire.Type, num wir
 		// TODO: C++ merges into oneofs, while v1 does not.
 		// TODO: C++ merges into oneofs, while v1 does not.
 		// Evaluate which behavior to pick.
 		// Evaluate which behavior to pick.
 		var m protoreflect.Message
 		var m protoreflect.Message
-		if knownFields.Has(num) && field.OneofType() == nil {
+		if knownFields.Has(num) && field.Oneof() == nil {
 			m = knownFields.Get(num).Message()
 			m = knownFields.Get(num).Message()
 		} else {
 		} else {
 			m = knownFields.NewMessage(num)
 			m = knownFields.NewMessage(num)
@@ -144,8 +144,8 @@ func (o UnmarshalOptions) unmarshalMap(b []byte, wtyp wire.Type, num wire.Number
 		return 0, wire.ParseError(n)
 		return 0, wire.ParseError(n)
 	}
 	}
 	var (
 	var (
-		keyField = field.MessageType().Fields().ByNumber(1)
-		valField = field.MessageType().Fields().ByNumber(2)
+		keyField = field.Message().Fields().ByNumber(1)
+		valField = field.Message().Fields().ByNumber(2)
 		key      protoreflect.Value
 		key      protoreflect.Value
 		val      protoreflect.Value
 		val      protoreflect.Value
 		haveKey  bool
 		haveKey  bool

+ 1 - 1
proto/encode.go

@@ -184,7 +184,7 @@ func (o MarshalOptions) marshalField(b []byte, field protoreflect.FieldDescripto
 		b = wire.AppendTag(b, num, wireTypes[kind])
 		b = wire.AppendTag(b, num, wireTypes[kind])
 		return o.marshalSingular(b, num, field, value)
 		return o.marshalSingular(b, num, field, value)
 	case field.IsMap():
 	case field.IsMap():
-		return o.marshalMap(b, num, kind, field.MessageType(), value.Map())
+		return o.marshalMap(b, num, kind, field.Message(), value.Map())
 	case field.IsPacked():
 	case field.IsPacked():
 		return o.marshalPacked(b, num, field, value.List())
 		return o.marshalPacked(b, num, field, value.List())
 	default:
 	default:

+ 3 - 3
proto/isinit.go

@@ -48,12 +48,12 @@ func isInitialized(m pref.Message, stack []interface{}) error {
 		}
 		}
 		// Look for fields containing a message: Messages, groups, and maps
 		// Look for fields containing a message: Messages, groups, and maps
 		// with a message or group value.
 		// with a message or group value.
-		ft := field.MessageType()
-		if ft == nil {
+		md := field.Message()
+		if md == nil {
 			return true
 			return true
 		}
 		}
 		if field.IsMap() {
 		if field.IsMap() {
-			if ft.Fields().ByNumber(2).MessageType() == nil {
+			if md.Fields().ByNumber(2).Message() == nil {
 				return true
 				return true
 			}
 			}
 		}
 		}

+ 1 - 1
proto/size.go

@@ -61,7 +61,7 @@ func sizeField(field protoreflect.FieldDescriptor, value protoreflect.Value) (si
 	case field.Cardinality() != protoreflect.Repeated:
 	case field.Cardinality() != protoreflect.Repeated:
 		return wire.SizeTag(num) + sizeSingular(num, kind, value)
 		return wire.SizeTag(num) + sizeSingular(num, kind, value)
 	case field.IsMap():
 	case field.IsMap():
-		return sizeMap(num, kind, field.MessageType(), value.Map())
+		return sizeMap(num, kind, field.Message(), value.Map())
 	case field.IsPacked():
 	case field.IsPacked():
 		return sizePacked(num, kind, value.List())
 		return sizePacked(num, kind, value.List())
 	default:
 	default:

+ 58 - 53
protogen/protogen.go

@@ -582,12 +582,12 @@ func newMessage(gen *Plugin, f *File, parent *Message, desc protoreflect.Message
 	seenOneofs := make(map[int]bool)
 	seenOneofs := make(map[int]bool)
 	for _, field := range message.Fields {
 	for _, field := range message.Fields {
 		field.GoName = makeNameUnique(field.GoName, true)
 		field.GoName = makeNameUnique(field.GoName, true)
-		if field.OneofType != nil {
-			if !seenOneofs[field.OneofType.Desc.Index()] {
+		if field.Oneof != nil {
+			if !seenOneofs[field.Oneof.Desc.Index()] {
 				// If this is a field in a oneof that we haven't seen before,
 				// If this is a field in a oneof that we haven't seen before,
 				// make the name for that oneof unique as well.
 				// make the name for that oneof unique as well.
-				field.OneofType.GoName = makeNameUnique(field.OneofType.GoName, false)
-				seenOneofs[field.OneofType.Desc.Index()] = true
+				field.Oneof.GoName = makeNameUnique(field.Oneof.GoName, false)
+				seenOneofs[field.Oneof.Desc.Index()] = true
 			}
 			}
 		}
 		}
 	}
 	}
@@ -626,32 +626,32 @@ type Field struct {
 	// '{{GoName}}' and a getter method named 'Get{{GoName}}'.
 	// '{{GoName}}' and a getter method named 'Get{{GoName}}'.
 	GoName string
 	GoName string
 
 
-	ParentMessage *Message // message in which this field is defined; nil if top-level extension
-	ExtendedType  *Message // extended message for extension fields; nil otherwise
-	MessageType   *Message // type for message or group fields; nil otherwise
-	EnumType      *Enum    // type for enum fields; nil otherwise
-	OneofType     *Oneof   // containing oneof; nil if not part of a oneof
-	Location      Location // location of this field
+	Parent   *Message // message in which this field is defined; nil if top-level extension
+	Oneof    *Oneof   // containing oneof; nil if not part of a oneof
+	Extendee *Message // extended message for extension fields; nil otherwise
+	Enum     *Enum    // type for enum fields; nil otherwise
+	Message  *Message // type for message or group fields; nil otherwise
+	Location Location // location of this field
 }
 }
 
 
 func newField(gen *Plugin, f *File, message *Message, desc protoreflect.FieldDescriptor) *Field {
 func newField(gen *Plugin, f *File, message *Message, desc protoreflect.FieldDescriptor) *Field {
 	var loc Location
 	var loc Location
 	switch {
 	switch {
-	case desc.ExtendedType() != nil && message == nil:
+	case desc.Extendee() != nil && message == nil:
 		loc = f.location(fieldnum.FileDescriptorProto_Extension, int32(desc.Index()))
 		loc = f.location(fieldnum.FileDescriptorProto_Extension, int32(desc.Index()))
-	case desc.ExtendedType() != nil && message != nil:
+	case desc.Extendee() != nil && message != nil:
 		loc = message.Location.appendPath(fieldnum.DescriptorProto_Extension, int32(desc.Index()))
 		loc = message.Location.appendPath(fieldnum.DescriptorProto_Extension, int32(desc.Index()))
 	default:
 	default:
 		loc = message.Location.appendPath(fieldnum.DescriptorProto_Field, int32(desc.Index()))
 		loc = message.Location.appendPath(fieldnum.DescriptorProto_Field, int32(desc.Index()))
 	}
 	}
 	field := &Field{
 	field := &Field{
-		Desc:          desc,
-		GoName:        camelCase(string(desc.Name())),
-		ParentMessage: message,
-		Location:      loc,
+		Desc:     desc,
+		GoName:   camelCase(string(desc.Name())),
+		Parent:   message,
+		Location: loc,
 	}
 	}
-	if desc.OneofType() != nil {
-		field.OneofType = message.Oneofs[desc.OneofType().Index()]
+	if desc.Oneof() != nil {
+		field.Oneof = message.Oneofs[desc.Oneof().Index()]
 	}
 	}
 	return field
 	return field
 }
 }
@@ -663,27 +663,27 @@ func (field *Field) init(gen *Plugin) error {
 	desc := field.Desc
 	desc := field.Desc
 	switch desc.Kind() {
 	switch desc.Kind() {
 	case protoreflect.MessageKind, protoreflect.GroupKind:
 	case protoreflect.MessageKind, protoreflect.GroupKind:
-		mname := desc.MessageType().FullName()
+		mname := desc.Message().FullName()
 		message, ok := gen.messagesByName[mname]
 		message, ok := gen.messagesByName[mname]
 		if !ok {
 		if !ok {
 			return fmt.Errorf("field %v: no descriptor for type %v", desc.FullName(), mname)
 			return fmt.Errorf("field %v: no descriptor for type %v", desc.FullName(), mname)
 		}
 		}
-		field.MessageType = message
+		field.Message = message
 	case protoreflect.EnumKind:
 	case protoreflect.EnumKind:
-		ename := field.Desc.EnumType().FullName()
+		ename := field.Desc.Enum().FullName()
 		enum, ok := gen.enumsByName[ename]
 		enum, ok := gen.enumsByName[ename]
 		if !ok {
 		if !ok {
 			return fmt.Errorf("field %v: no descriptor for enum %v", desc.FullName(), ename)
 			return fmt.Errorf("field %v: no descriptor for enum %v", desc.FullName(), ename)
 		}
 		}
-		field.EnumType = enum
+		field.Enum = enum
 	}
 	}
-	if desc.ExtendedType() != nil {
-		mname := desc.ExtendedType().FullName()
+	if desc.Extendee() != nil {
+		mname := desc.Extendee().FullName()
 		message, ok := gen.messagesByName[mname]
 		message, ok := gen.messagesByName[mname]
 		if !ok {
 		if !ok {
 			return fmt.Errorf("field %v: no descriptor for type %v", desc.FullName(), mname)
 			return fmt.Errorf("field %v: no descriptor for type %v", desc.FullName(), mname)
 		}
 		}
-		field.ExtendedType = message
+		field.Extendee = message
 	}
 	}
 	return nil
 	return nil
 }
 }
@@ -692,18 +692,19 @@ func (field *Field) init(gen *Plugin) error {
 type Oneof struct {
 type Oneof struct {
 	Desc protoreflect.OneofDescriptor
 	Desc protoreflect.OneofDescriptor
 
 
-	GoName        string   // Go field name of this oneof
-	ParentMessage *Message // message in which this oneof occurs
-	Fields        []*Field // fields that are part of this oneof
-	Location      Location // location of this oneof
+	GoName string   // Go field name of this oneof
+	Parent *Message // message in which this oneof occurs
+	Fields []*Field // fields that are part of this oneof
+
+	Location Location // location of this oneof
 }
 }
 
 
 func newOneof(gen *Plugin, f *File, message *Message, desc protoreflect.OneofDescriptor) *Oneof {
 func newOneof(gen *Plugin, f *File, message *Message, desc protoreflect.OneofDescriptor) *Oneof {
 	return &Oneof{
 	return &Oneof{
-		Desc:          desc,
-		ParentMessage: message,
-		GoName:        camelCase(string(desc.Name())),
-		Location:      message.Location.appendPath(fieldnum.DescriptorProto_OneofDecl, int32(desc.Index())),
+		Desc:     desc,
+		Parent:   message,
+		GoName:   camelCase(string(desc.Name())),
+		Location: message.Location.appendPath(fieldnum.DescriptorProto_OneofDecl, int32(desc.Index())),
 	}
 	}
 }
 }
 
 
@@ -717,9 +718,10 @@ func (oneof *Oneof) init(gen *Plugin, parent *Message) {
 type Enum struct {
 type Enum struct {
 	Desc protoreflect.EnumDescriptor
 	Desc protoreflect.EnumDescriptor
 
 
-	GoIdent  GoIdent      // name of the generated Go type
-	Values   []*EnumValue // enum values
-	Location Location     // location of this enum
+	GoIdent GoIdent      // name of the generated Go type
+	Values  []*EnumValue // enum values
+
+	Location Location // location of this enum
 }
 }
 
 
 func newEnum(gen *Plugin, f *File, parent *Message, desc protoreflect.EnumDescriptor) *Enum {
 func newEnum(gen *Plugin, f *File, parent *Message, desc protoreflect.EnumDescriptor) *Enum {
@@ -745,7 +747,8 @@ func newEnum(gen *Plugin, f *File, parent *Message, desc protoreflect.EnumDescri
 type EnumValue struct {
 type EnumValue struct {
 	Desc protoreflect.EnumValueDescriptor
 	Desc protoreflect.EnumValueDescriptor
 
 
-	GoIdent  GoIdent  // name of the generated Go type
+	GoIdent GoIdent // name of the generated Go type
+
 	Location Location // location of this enum value
 	Location Location // location of this enum value
 }
 }
 
 
@@ -770,9 +773,10 @@ func newEnumValue(gen *Plugin, f *File, message *Message, enum *Enum, desc proto
 type Service struct {
 type Service struct {
 	Desc protoreflect.ServiceDescriptor
 	Desc protoreflect.ServiceDescriptor
 
 
-	GoName   string
-	Location Location  // location of this service
-	Methods  []*Method // service method definitions
+	GoName  string
+	Methods []*Method // service method definitions
+
+	Location Location // location of this service
 }
 }
 
 
 func newService(gen *Plugin, f *File, desc protoreflect.ServiceDescriptor) *Service {
 func newService(gen *Plugin, f *File, desc protoreflect.ServiceDescriptor) *Service {
@@ -791,19 +795,20 @@ func newService(gen *Plugin, f *File, desc protoreflect.ServiceDescriptor) *Serv
 type Method struct {
 type Method struct {
 	Desc protoreflect.MethodDescriptor
 	Desc protoreflect.MethodDescriptor
 
 
-	GoName        string
-	ParentService *Service
-	Location      Location // location of this method
-	InputType     *Message
-	OutputType    *Message
+	GoName string
+	Parent *Service
+	Input  *Message
+	Output *Message
+
+	Location Location // location of this method
 }
 }
 
 
 func newMethod(gen *Plugin, f *File, service *Service, desc protoreflect.MethodDescriptor) *Method {
 func newMethod(gen *Plugin, f *File, service *Service, desc protoreflect.MethodDescriptor) *Method {
 	method := &Method{
 	method := &Method{
-		Desc:          desc,
-		GoName:        camelCase(string(desc.Name())),
-		ParentService: service,
-		Location:      service.Location.appendPath(fieldnum.ServiceDescriptorProto_Method, int32(desc.Index())),
+		Desc:     desc,
+		GoName:   camelCase(string(desc.Name())),
+		Parent:   service,
+		Location: service.Location.appendPath(fieldnum.ServiceDescriptorProto_Method, int32(desc.Index())),
 	}
 	}
 	return method
 	return method
 }
 }
@@ -811,19 +816,19 @@ func newMethod(gen *Plugin, f *File, service *Service, desc protoreflect.MethodD
 func (method *Method) init(gen *Plugin) error {
 func (method *Method) init(gen *Plugin) error {
 	desc := method.Desc
 	desc := method.Desc
 
 
-	inName := desc.InputType().FullName()
+	inName := desc.Input().FullName()
 	in, ok := gen.messagesByName[inName]
 	in, ok := gen.messagesByName[inName]
 	if !ok {
 	if !ok {
 		return fmt.Errorf("method %v: no descriptor for type %v", desc.FullName(), inName)
 		return fmt.Errorf("method %v: no descriptor for type %v", desc.FullName(), inName)
 	}
 	}
-	method.InputType = in
+	method.Input = in
 
 
-	outName := desc.OutputType().FullName()
+	outName := desc.Output().FullName()
 	out, ok := gen.messagesByName[outName]
 	out, ok := gen.messagesByName[outName]
 	if !ok {
 	if !ok {
 		return fmt.Errorf("method %v: no descriptor for type %v", desc.FullName(), outName)
 		return fmt.Errorf("method %v: no descriptor for type %v", desc.FullName(), outName)
 	}
 	}
-	method.OutputType = out
+	method.Output = out
 
 
 	return nil
 	return nil
 }
 }

+ 6 - 6
reflect/protodesc/toproto.go

@@ -100,14 +100,14 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
 		Number:   scalar.Int32(int32(field.Number())),
 		Number:   scalar.Int32(int32(field.Number())),
 		Label:    descriptorpb.FieldDescriptorProto_Label(field.Cardinality()).Enum(),
 		Label:    descriptorpb.FieldDescriptorProto_Label(field.Cardinality()).Enum(),
 		Type:     descriptorpb.FieldDescriptorProto_Type(field.Kind()).Enum(),
 		Type:     descriptorpb.FieldDescriptorProto_Type(field.Kind()).Enum(),
-		Extendee: fullNameOf(field.ExtendedType()),
+		Extendee: fullNameOf(field.Extendee()),
 		Options:  field.Options().(*descriptorpb.FieldOptions),
 		Options:  field.Options().(*descriptorpb.FieldOptions),
 	}
 	}
 	switch field.Kind() {
 	switch field.Kind() {
 	case protoreflect.EnumKind:
 	case protoreflect.EnumKind:
-		p.TypeName = fullNameOf(field.EnumType())
+		p.TypeName = fullNameOf(field.Enum())
 	case protoreflect.MessageKind, protoreflect.GroupKind:
 	case protoreflect.MessageKind, protoreflect.GroupKind:
-		p.TypeName = fullNameOf(field.MessageType())
+		p.TypeName = fullNameOf(field.Message())
 	}
 	}
 	if field.HasJSONName() {
 	if field.HasJSONName() {
 		p.JsonName = scalar.String(field.JSONName())
 		p.JsonName = scalar.String(field.JSONName())
@@ -125,7 +125,7 @@ func ToFieldDescriptorProto(field protoreflect.FieldDescriptor) *descriptorpb.Fi
 			p.DefaultValue = scalar.String(def)
 			p.DefaultValue = scalar.String(def)
 		}
 		}
 	}
 	}
-	if oneof := field.OneofType(); oneof != nil {
+	if oneof := field.Oneof(); oneof != nil {
 		p.OneofIndex = scalar.Int32(int32(oneof.Index()))
 		p.OneofIndex = scalar.Int32(int32(oneof.Index()))
 	}
 	}
 	return p
 	return p
@@ -191,8 +191,8 @@ func ToServiceDescriptorProto(service protoreflect.ServiceDescriptor) *descripto
 func ToMethodDescriptorProto(method protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {
 func ToMethodDescriptorProto(method protoreflect.MethodDescriptor) *descriptorpb.MethodDescriptorProto {
 	p := &descriptorpb.MethodDescriptorProto{
 	p := &descriptorpb.MethodDescriptorProto{
 		Name:       scalar.String(string(method.Name())),
 		Name:       scalar.String(string(method.Name())),
-		InputType:  fullNameOf(method.InputType()),
-		OutputType: fullNameOf(method.OutputType()),
+		InputType:  fullNameOf(method.Input()),
+		OutputType: fullNameOf(method.Output()),
 		Options:    method.Options().(*descriptorpb.MethodOptions),
 		Options:    method.Options().(*descriptorpb.MethodOptions),
 	}
 	}
 	if method.IsStreamingClient() {
 	if method.IsStreamingClient() {

+ 34 - 14
reflect/protoreflect/type.go

@@ -297,26 +297,39 @@ type FieldDescriptor interface {
 	// The Value type is determined by the Kind.
 	// The Value type is determined by the Kind.
 	Default() Value
 	Default() Value
 
 
-	// DefaultEnumValue returns the EnummValueDescriptor for the default value
+	// DefaultEnumValue returns the EnumValueDescriptor for the default value
 	// of an enum field, and is nil for any other kind of field.
 	// of an enum field, and is nil for any other kind of field.
 	DefaultEnumValue() EnumValueDescriptor
 	DefaultEnumValue() EnumValueDescriptor
 
 
-	// OneofType is the containing oneof that this field belongs to,
+	// Oneof is the containing oneof that this field belongs to,
 	// and is nil if this field is not part of a oneof.
 	// and is nil if this field is not part of a oneof.
-	OneofType() OneofDescriptor
+	Oneof() OneofDescriptor
 
 
-	// ExtendedType returns a MessageDescriptor for the extended message
+	// Extendee returns a message descriptor for the extended message
 	// that this extension field belongs in.
 	// that this extension field belongs in.
 	// It returns nil if this field is not an extension.
 	// It returns nil if this field is not an extension.
-	ExtendedType() MessageDescriptor
+	Extendee() MessageDescriptor
 
 
-	// MessageType is the message type if Kind is MessageKind or GroupKind.
+	// Enum is the enum descriptor if Kind is EnumKind.
 	// It returns nil for any other Kind.
 	// It returns nil for any other Kind.
-	MessageType() MessageDescriptor
+	Enum() EnumDescriptor
 
 
-	// EnumType is the enum type if Kind is EnumKind.
-	// It returns nil for any other Kind.
+	// Message is the message descriptor if Kind is
+	// MessageKind or GroupKind. It returns nil for any other Kind.
+	Message() MessageDescriptor
+
+	// OneofType has been renamed to Oneof.
+	// Deprecated: Use Oneof instead; this will be removed.
+	OneofType() OneofDescriptor
+	// ExtendedType has been renamed to Extendee.
+	// Deprecated: Use Extendee instead; this will be removed.
+	ExtendedType() MessageDescriptor
+	// EnumType has been renamed to Enum.
+	// Deprecated: Use Enum instead; this will be removed.
 	EnumType() EnumDescriptor
 	EnumType() EnumDescriptor
+	// MessageType has been renamed to Message.
+	// Deprecated: Use Message instead; this will be removed.
+	MessageType() MessageDescriptor
 
 
 	isFieldDescriptor
 	isFieldDescriptor
 }
 }
@@ -387,7 +400,7 @@ type ExtensionDescriptors interface {
 //
 //
 // While a normal field is a member of the parent message that it is declared
 // While a normal field is a member of the parent message that it is declared
 // within (see Descriptor.Parent), an extension field is a member of some other
 // within (see Descriptor.Parent), an extension field is a member of some other
-// target message (see ExtensionDescriptor.ExtendedType) and may have no
+// target message (see ExtensionDescriptor.Extendee) and may have no
 // relationship with the parent. However, the full name of an extension field is
 // relationship with the parent. However, the full name of an extension field is
 // relative to the parent that it is declared within.
 // relative to the parent that it is declared within.
 //
 //
@@ -550,15 +563,22 @@ type ServiceDescriptors interface {
 type MethodDescriptor interface {
 type MethodDescriptor interface {
 	Descriptor
 	Descriptor
 
 
-	// InputType is the input message type.
-	InputType() MessageDescriptor
-	// OutputType is the output message type.
-	OutputType() MessageDescriptor
+	// Input is the input message descriptor.
+	Input() MessageDescriptor
+	// Output is the output message descriptor.
+	Output() MessageDescriptor
 	// IsStreamingClient reports whether the client streams multiple messages.
 	// IsStreamingClient reports whether the client streams multiple messages.
 	IsStreamingClient() bool
 	IsStreamingClient() bool
 	// IsStreamingServer reports whether the server streams multiple messages.
 	// IsStreamingServer reports whether the server streams multiple messages.
 	IsStreamingServer() bool
 	IsStreamingServer() bool
 
 
+	// InputType has been renamed to Input.
+	// Deprecated: Use Input instead; this will be removed.
+	InputType() MessageDescriptor
+	// OutputType has been renamed to Output.
+	// Deprecated: Use Output instead; this will be removed.
+	OutputType() MessageDescriptor
+
 	isMethodDescriptor
 	isMethodDescriptor
 }
 }
 type isMethodDescriptor interface{ ProtoType(MethodDescriptor) }
 type isMethodDescriptor interface{ ProtoType(MethodDescriptor) }

+ 1 - 1
reflect/protoregistry/registry.go

@@ -372,7 +372,7 @@ typeLoop:
 			// Check for conflicts in extensionsByMessage.
 			// Check for conflicts in extensionsByMessage.
 			if xt, _ := typ.(protoreflect.ExtensionType); xt != nil {
 			if xt, _ := typ.(protoreflect.ExtensionType); xt != nil {
 				field := xt.Number()
 				field := xt.Number()
-				message := xt.ExtendedType().FullName()
+				message := xt.Extendee().FullName()
 				if r.extensionsByMessage[message][field] != nil {
 				if r.extensionsByMessage[message][field] != nil {
 					if firstErr == nil {
 					if firstErr == nil {
 						firstErr = errors.New("extension %v is already registered on message %v", name, message)
 						firstErr = errors.New("extension %v is already registered on message %v", name, message)