cmd/protoc-gen-go: generate oneof types seperately

Seperate out the generation of the oneof wrapper types from the
code block that is about getter methods.

Change-Id: Ief44ef953d0b5ad8c998a8542c830ca70468a3bf
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/171029
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/main.go b/cmd/protoc-gen-go/internal_gengo/main.go
index 1b05a43..1b8b332 100644
--- a/cmd/protoc-gen-go/internal_gengo/main.go
+++ b/cmd/protoc-gen-go/internal_gengo/main.go
@@ -476,10 +476,8 @@
 
 	// Getter methods.
 	for _, field := range message.Fields {
-		if field.OneofType != nil {
-			if field == field.OneofType.Fields[0] {
-				genOneofTypes(gen, g, f, message, field.OneofType)
-			}
+		if isFirstOneofField(field) {
+			genOneofGetter(gen, g, f, message, field.OneofType)
 		}
 		goType, pointer := fieldGoType(g, field)
 		defaultValue := fieldDefaultValue(g, message, field)
@@ -510,9 +508,15 @@
 		g.P()
 	}
 
+	// XXX_OneofWrappers method.
 	if len(message.Oneofs) > 0 {
 		genOneofWrappers(gen, g, f, message)
 	}
+
+	// Oneof wrapper types.
+	for _, oneof := range message.Oneofs {
+		genOneofTypes(gen, g, f, message, oneof)
+	}
 }
 
 // fieldGoType returns the Go type used for a field.
@@ -739,11 +743,35 @@
 	g.P(oneofFieldName(oneof), " ", oneofInterfaceName(oneof), " `protobuf_oneof:\"", oneof.Desc.Name(), "\"`")
 }
 
+// genOneofGetter generate a Get method for a oneof.
+func genOneofGetter(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, message *protogen.Message, oneof *protogen.Oneof) {
+	g.Annotate(message.GoIdent.GoName+".Get"+oneof.GoName, oneof.Location)
+	g.P("func (m *", message.GoIdent.GoName, ") Get", oneof.GoName, "() ", oneofInterfaceName(oneof), " {")
+	g.P("if m != nil {")
+	g.P("return m.", oneofFieldName(oneof))
+	g.P("}")
+	g.P("return nil")
+	g.P("}")
+	g.P()
+}
+
+// genOneofWrappers generates the XXX_OneofWrappers method for a message.
+func genOneofWrappers(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, message *protogen.Message) {
+	g.P("// XXX_OneofWrappers is for the internal use of the proto package.")
+	g.P("func (*", message.GoIdent.GoName, ") XXX_OneofWrappers() []interface{} {")
+	g.P("return []interface{}{")
+	for _, oneof := range message.Oneofs {
+		for _, field := range oneof.Fields {
+			g.P("(*", fieldOneofType(field), ")(nil),")
+		}
+	}
+	g.P("}")
+	g.P("}")
+	g.P()
+}
+
 // genOneofTypes generates the interface type used for a oneof field,
 // and the wrapper types that satisfy that interface.
-//
-// It also generates the getter method for the parent oneof field
-// (but not the member fields).
 func genOneofTypes(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, message *protogen.Message, oneof *protogen.Oneof) {
 	ifName := oneofInterfaceName(oneof)
 	g.P("type ", ifName, " interface {")
@@ -767,14 +795,11 @@
 		g.P("func (*", fieldOneofType(field), ") ", ifName, "() {}")
 		g.P()
 	}
-	g.Annotate(message.GoIdent.GoName+".Get"+oneof.GoName, oneof.Location)
-	g.P("func (m *", message.GoIdent.GoName, ") Get", oneof.GoName, "() ", ifName, " {")
-	g.P("if m != nil {")
-	g.P("return m.", oneofFieldName(oneof))
-	g.P("}")
-	g.P("return nil")
-	g.P("}")
-	g.P()
+}
+
+// isFirstOneofField reports whether this is the first field in a oneof.
+func isFirstOneofField(field *protogen.Field) bool {
+	return field.OneofType != nil && field.OneofType.Fields[0] == field
 }
 
 // oneofFieldName returns the name of the struct field holding the oneof value.
@@ -791,21 +816,6 @@
 	return fmt.Sprintf("is%s_%s", oneof.ParentMessage.GoIdent.GoName, oneof.GoName)
 }
 
-// genOneofWrappers generates the XXX_OneofWrappers method for a message.
-func genOneofWrappers(gen *protogen.Plugin, g *protogen.GeneratedFile, f *fileInfo, message *protogen.Message) {
-	g.P("// XXX_OneofWrappers is for the internal use of the proto package.")
-	g.P("func (*", message.GoIdent.GoName, ") XXX_OneofWrappers() []interface{} {")
-	g.P("return []interface{}{")
-	for _, oneof := range message.Oneofs {
-		for _, field := range oneof.Fields {
-			g.P("(*", fieldOneofType(field), ")(nil),")
-		}
-	}
-	g.P("}")
-	g.P("}")
-	g.P()
-}
-
 // fieldOneofType returns the wrapper type used to represent a field in a oneof.
 func fieldOneofType(field *protogen.Field) protogen.GoIdent {
 	ident := protogen.GoIdent{
diff --git a/cmd/protoc-gen-go/testdata/comments/comments.pb.go b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
index 4f973b2..af8e8c5 100644
--- a/cmd/protoc-gen-go/testdata/comments/comments.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/comments.pb.go
@@ -60,16 +60,6 @@
 	return ""
 }
 
-type isMessage1_Oneof1A interface {
-	isMessage1_Oneof1A()
-}
-
-type Message1_Oneof1AField1 struct {
-	Oneof1AField1 string `protobuf:"bytes,2,opt,name=Oneof1AField1,oneof"`
-}
-
-func (*Message1_Oneof1AField1) isMessage1_Oneof1A() {}
-
 func (m *Message1) GetOneof1A() isMessage1_Oneof1A {
 	if m != nil {
 		return m.Oneof1A
@@ -91,6 +81,16 @@
 	}
 }
 
+type isMessage1_Oneof1A interface {
+	isMessage1_Oneof1A()
+}
+
+type Message1_Oneof1AField1 struct {
+	Oneof1AField1 string `protobuf:"bytes,2,opt,name=Oneof1AField1,oneof"`
+}
+
+func (*Message1_Oneof1AField1) isMessage1_Oneof1A() {}
+
 // COMMENT: Message2
 type Message2 struct {
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
diff --git a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
index b8832bd..88e0b7d 100644
--- a/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
+++ b/cmd/protoc-gen-go/testdata/fieldnames/fieldnames.pb.go
@@ -179,16 +179,6 @@
 	return ""
 }
 
-type isMessage_OneofConflictA_ interface {
-	isMessage_OneofConflictA_()
-}
-
-type Message_OneofConflictA struct {
-	OneofConflictA string `protobuf:"bytes,40,opt,name=OneofConflictA,oneof"`
-}
-
-func (*Message_OneofConflictA) isMessage_OneofConflictA_() {}
-
 func (m *Message) GetOneofConflictA_() isMessage_OneofConflictA_ {
 	if m != nil {
 		return m.OneofConflictA_
@@ -203,22 +193,6 @@
 	return ""
 }
 
-type isMessage_OneofConflictB interface {
-	isMessage_OneofConflictB()
-}
-
-type Message_OneofNoConflict struct {
-	OneofNoConflict string `protobuf:"bytes,50,opt,name=oneof_no_conflict,json=oneofNoConflict,oneof"`
-}
-
-type Message_OneofConflictB_ struct {
-	OneofConflictB_ string `protobuf:"bytes,51,opt,name=OneofConflictB,oneof"`
-}
-
-func (*Message_OneofNoConflict) isMessage_OneofConflictB() {}
-
-func (*Message_OneofConflictB_) isMessage_OneofConflictB() {}
-
 func (m *Message) GetOneofConflictB() isMessage_OneofConflictB {
 	if m != nil {
 		return m.OneofConflictB
@@ -240,16 +214,6 @@
 	return ""
 }
 
-type isMessage_OneofConflictC interface {
-	isMessage_OneofConflictC()
-}
-
-type Message_OneofMessageConflict_ struct {
-	OneofMessageConflict string `protobuf:"bytes,60,opt,name=oneof_message_conflict,json=oneofMessageConflict,oneof"`
-}
-
-func (*Message_OneofMessageConflict_) isMessage_OneofConflictC() {}
-
 func (m *Message) GetOneofConflictC() isMessage_OneofConflictC {
 	if m != nil {
 		return m.OneofConflictC
@@ -274,6 +238,42 @@
 	}
 }
 
+type isMessage_OneofConflictA_ interface {
+	isMessage_OneofConflictA_()
+}
+
+type Message_OneofConflictA struct {
+	OneofConflictA string `protobuf:"bytes,40,opt,name=OneofConflictA,oneof"`
+}
+
+func (*Message_OneofConflictA) isMessage_OneofConflictA_() {}
+
+type isMessage_OneofConflictB interface {
+	isMessage_OneofConflictB()
+}
+
+type Message_OneofNoConflict struct {
+	OneofNoConflict string `protobuf:"bytes,50,opt,name=oneof_no_conflict,json=oneofNoConflict,oneof"`
+}
+
+type Message_OneofConflictB_ struct {
+	OneofConflictB_ string `protobuf:"bytes,51,opt,name=OneofConflictB,oneof"`
+}
+
+func (*Message_OneofNoConflict) isMessage_OneofConflictB() {}
+
+func (*Message_OneofConflictB_) isMessage_OneofConflictB() {}
+
+type isMessage_OneofConflictC interface {
+	isMessage_OneofConflictC()
+}
+
+type Message_OneofMessageConflict_ struct {
+	OneofMessageConflict string `protobuf:"bytes,60,opt,name=oneof_message_conflict,json=oneofMessageConflict,oneof"`
+}
+
+func (*Message_OneofMessageConflict_) isMessage_OneofConflictC() {}
+
 type Message_OneofMessageConflict struct {
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`
 	XXX_unrecognized     []byte   `json:"-"`
diff --git a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
index 053bfb0..cf4e72c 100644
--- a/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
+++ b/cmd/protoc-gen-go/testdata/import_public/sub/a.pb.go
@@ -241,22 +241,6 @@
 	return Default_M_F
 }
 
-type isM_OneofField interface {
-	isM_OneofField()
-}
-
-type M_OneofInt32 struct {
-	OneofInt32 int32 `protobuf:"varint,2,opt,name=oneof_int32,json=oneofInt32,oneof"`
-}
-
-type M_OneofInt64 struct {
-	OneofInt64 int64 `protobuf:"varint,3,opt,name=oneof_int64,json=oneofInt64,oneof"`
-}
-
-func (*M_OneofInt32) isM_OneofField() {}
-
-func (*M_OneofInt64) isM_OneofField() {}
-
 func (m *M) GetOneofField() isM_OneofField {
 	if m != nil {
 		return m.OneofField
@@ -286,6 +270,22 @@
 	}
 }
 
+type isM_OneofField interface {
+	isM_OneofField()
+}
+
+type M_OneofInt32 struct {
+	OneofInt32 int32 `protobuf:"varint,2,opt,name=oneof_int32,json=oneofInt32,oneof"`
+}
+
+type M_OneofInt64 struct {
+	OneofInt64 int64 `protobuf:"varint,3,opt,name=oneof_int64,json=oneofInt64,oneof"`
+}
+
+func (*M_OneofInt32) isM_OneofField() {}
+
+func (*M_OneofInt64) isM_OneofField() {}
+
 type M_Submessage struct {
 	// Types that are valid to be assigned to SubmessageOneofField:
 	//	*M_Submessage_SubmessageOneofInt32
@@ -319,22 +319,6 @@
 	return xxx_File_import_public_sub_a_proto_rawDescGZIP(), []int{0, 0}
 }
 
-type isM_Submessage_SubmessageOneofField interface {
-	isM_Submessage_SubmessageOneofField()
-}
-
-type M_Submessage_SubmessageOneofInt32 struct {
-	SubmessageOneofInt32 int32 `protobuf:"varint,1,opt,name=submessage_oneof_int32,json=submessageOneofInt32,oneof"`
-}
-
-type M_Submessage_SubmessageOneofInt64 struct {
-	SubmessageOneofInt64 int64 `protobuf:"varint,2,opt,name=submessage_oneof_int64,json=submessageOneofInt64,oneof"`
-}
-
-func (*M_Submessage_SubmessageOneofInt32) isM_Submessage_SubmessageOneofField() {}
-
-func (*M_Submessage_SubmessageOneofInt64) isM_Submessage_SubmessageOneofField() {}
-
 func (m *M_Submessage) GetSubmessageOneofField() isM_Submessage_SubmessageOneofField {
 	if m != nil {
 		return m.SubmessageOneofField
@@ -364,6 +348,22 @@
 	}
 }
 
+type isM_Submessage_SubmessageOneofField interface {
+	isM_Submessage_SubmessageOneofField()
+}
+
+type M_Submessage_SubmessageOneofInt32 struct {
+	SubmessageOneofInt32 int32 `protobuf:"varint,1,opt,name=submessage_oneof_int32,json=submessageOneofInt32,oneof"`
+}
+
+type M_Submessage_SubmessageOneofInt64 struct {
+	SubmessageOneofInt64 int64 `protobuf:"varint,2,opt,name=submessage_oneof_int64,json=submessageOneofInt64,oneof"`
+}
+
+func (*M_Submessage_SubmessageOneofInt32) isM_Submessage_SubmessageOneofField() {}
+
+func (*M_Submessage_SubmessageOneofInt64) isM_Submessage_SubmessageOneofField() {}
+
 var xxx_File_import_public_sub_a_proto_extDescs = []protoiface.ExtensionDescV1{
 	{
 		ExtendedType:  (*M)(nil),
diff --git a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
index 36cc583..a484165 100644
--- a/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
+++ b/cmd/protoc-gen-go/testdata/issue780_oneof_conflict/test.pb.go
@@ -45,16 +45,6 @@
 	return xxx_File_issue780_oneof_conflict_test_proto_rawDescGZIP(), []int{0}
 }
 
-type isFoo_Bar interface {
-	isFoo_Bar()
-}
-
-type Foo_GetBar struct {
-	GetBar string `protobuf:"bytes,1,opt,name=get_bar,json=getBar,oneof"`
-}
-
-func (*Foo_GetBar) isFoo_Bar() {}
-
 func (m *Foo) GetBar() isFoo_Bar {
 	if m != nil {
 		return m.Bar
@@ -76,6 +66,16 @@
 	}
 }
 
+type isFoo_Bar interface {
+	isFoo_Bar()
+}
+
+type Foo_GetBar struct {
+	GetBar string `protobuf:"bytes,1,opt,name=get_bar,json=getBar,oneof"`
+}
+
+func (*Foo_GetBar) isFoo_Bar() {}
+
 var File_issue780_oneof_conflict_test_proto protoreflect.FileDescriptor
 
 var xxx_File_issue780_oneof_conflict_test_proto_rawDesc = []byte{
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index 6906ece..2134518 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -794,124 +794,6 @@
 	return nil
 }
 
-type isFieldTestMessage_OneofField interface {
-	isFieldTestMessage_OneofField()
-}
-
-type FieldTestMessage_OneofBool struct {
-	OneofBool bool `protobuf:"varint,601,opt,name=oneof_bool,json=oneofBool,oneof"`
-}
-
-type FieldTestMessage_OneofEnum struct {
-	OneofEnum FieldTestMessage_Enum `protobuf:"varint,602,opt,name=oneof_enum,json=oneofEnum,enum=goproto.protoc.proto2.FieldTestMessage_Enum,oneof"`
-}
-
-type FieldTestMessage_OneofInt32 struct {
-	OneofInt32 int32 `protobuf:"varint,603,opt,name=oneof_int32,json=oneofInt32,oneof"`
-}
-
-type FieldTestMessage_OneofSint32 struct {
-	OneofSint32 int32 `protobuf:"zigzag32,604,opt,name=oneof_sint32,json=oneofSint32,oneof"`
-}
-
-type FieldTestMessage_OneofUint32 struct {
-	OneofUint32 uint32 `protobuf:"varint,605,opt,name=oneof_uint32,json=oneofUint32,oneof"`
-}
-
-type FieldTestMessage_OneofInt64 struct {
-	OneofInt64 int64 `protobuf:"varint,606,opt,name=oneof_int64,json=oneofInt64,oneof"`
-}
-
-type FieldTestMessage_OneofSint64 struct {
-	OneofSint64 int64 `protobuf:"zigzag64,607,opt,name=oneof_sint64,json=oneofSint64,oneof"`
-}
-
-type FieldTestMessage_OneofUint64 struct {
-	OneofUint64 uint64 `protobuf:"varint,608,opt,name=oneof_uint64,json=oneofUint64,oneof"`
-}
-
-type FieldTestMessage_OneofSfixed32 struct {
-	OneofSfixed32 int32 `protobuf:"fixed32,609,opt,name=oneof_sfixed32,json=oneofSfixed32,oneof"`
-}
-
-type FieldTestMessage_OneofFixed32 struct {
-	OneofFixed32 uint32 `protobuf:"fixed32,610,opt,name=oneof_fixed32,json=oneofFixed32,oneof"`
-}
-
-type FieldTestMessage_OneofFloat struct {
-	OneofFloat float32 `protobuf:"fixed32,611,opt,name=oneof_float,json=oneofFloat,oneof"`
-}
-
-type FieldTestMessage_OneofSfixed64 struct {
-	OneofSfixed64 int64 `protobuf:"fixed64,612,opt,name=oneof_sfixed64,json=oneofSfixed64,oneof"`
-}
-
-type FieldTestMessage_OneofFixed64 struct {
-	OneofFixed64 uint64 `protobuf:"fixed64,613,opt,name=oneof_fixed64,json=oneofFixed64,oneof"`
-}
-
-type FieldTestMessage_OneofDouble struct {
-	OneofDouble float64 `protobuf:"fixed64,614,opt,name=oneof_double,json=oneofDouble,oneof"`
-}
-
-type FieldTestMessage_OneofString struct {
-	OneofString string `protobuf:"bytes,615,opt,name=oneof_string,json=oneofString,oneof"`
-}
-
-type FieldTestMessage_OneofBytes struct {
-	OneofBytes []byte `protobuf:"bytes,616,opt,name=oneof_bytes,json=oneofBytes,oneof"`
-}
-
-type FieldTestMessage_Oneof_Message struct {
-	Oneof_Message *FieldTestMessage_Message `protobuf:"bytes,617,opt,name=oneof_Message,json=oneofMessage,oneof"`
-}
-
-type FieldTestMessage_Oneofgroup struct {
-	Oneofgroup *FieldTestMessage_OneofGroup `protobuf:"group,618,opt,name=OneofGroup,json=oneofgroup,oneof"`
-}
-
-type FieldTestMessage_OneofLargestTag struct {
-	OneofLargestTag int32 `protobuf:"varint,536870911,opt,name=oneof_largest_tag,json=oneofLargestTag,oneof"`
-}
-
-func (*FieldTestMessage_OneofBool) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofEnum) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofInt32) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofSint32) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofUint32) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofInt64) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofSint64) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofUint64) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofSfixed32) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofFixed32) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofFloat) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofSfixed64) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofFixed64) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofDouble) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofString) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofBytes) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_Oneof_Message) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_Oneofgroup) isFieldTestMessage_OneofField() {}
-
-func (*FieldTestMessage_OneofLargestTag) isFieldTestMessage_OneofField() {}
-
 func (m *FieldTestMessage) GetOneofField() isFieldTestMessage_OneofField {
 	if m != nil {
 		return m.OneofField
@@ -1052,22 +934,6 @@
 	return 0
 }
 
-type isFieldTestMessage_OneofTwo interface {
-	isFieldTestMessage_OneofTwo()
-}
-
-type FieldTestMessage_OneofTwo_1 struct {
-	OneofTwo_1 int32 `protobuf:"varint,700,opt,name=oneof_two_1,json=oneofTwo1,oneof"`
-}
-
-type FieldTestMessage_OneofTwo_2 struct {
-	OneofTwo_2 int64 `protobuf:"varint,701,opt,name=oneof_two_2,json=oneofTwo2,oneof"`
-}
-
-func (*FieldTestMessage_OneofTwo_1) isFieldTestMessage_OneofTwo() {}
-
-func (*FieldTestMessage_OneofTwo_2) isFieldTestMessage_OneofTwo() {}
-
 func (m *FieldTestMessage) GetOneofTwo() isFieldTestMessage_OneofTwo {
 	if m != nil {
 		return m.OneofTwo
@@ -1116,6 +982,140 @@
 	}
 }
 
+type isFieldTestMessage_OneofField interface {
+	isFieldTestMessage_OneofField()
+}
+
+type FieldTestMessage_OneofBool struct {
+	OneofBool bool `protobuf:"varint,601,opt,name=oneof_bool,json=oneofBool,oneof"`
+}
+
+type FieldTestMessage_OneofEnum struct {
+	OneofEnum FieldTestMessage_Enum `protobuf:"varint,602,opt,name=oneof_enum,json=oneofEnum,enum=goproto.protoc.proto2.FieldTestMessage_Enum,oneof"`
+}
+
+type FieldTestMessage_OneofInt32 struct {
+	OneofInt32 int32 `protobuf:"varint,603,opt,name=oneof_int32,json=oneofInt32,oneof"`
+}
+
+type FieldTestMessage_OneofSint32 struct {
+	OneofSint32 int32 `protobuf:"zigzag32,604,opt,name=oneof_sint32,json=oneofSint32,oneof"`
+}
+
+type FieldTestMessage_OneofUint32 struct {
+	OneofUint32 uint32 `protobuf:"varint,605,opt,name=oneof_uint32,json=oneofUint32,oneof"`
+}
+
+type FieldTestMessage_OneofInt64 struct {
+	OneofInt64 int64 `protobuf:"varint,606,opt,name=oneof_int64,json=oneofInt64,oneof"`
+}
+
+type FieldTestMessage_OneofSint64 struct {
+	OneofSint64 int64 `protobuf:"zigzag64,607,opt,name=oneof_sint64,json=oneofSint64,oneof"`
+}
+
+type FieldTestMessage_OneofUint64 struct {
+	OneofUint64 uint64 `protobuf:"varint,608,opt,name=oneof_uint64,json=oneofUint64,oneof"`
+}
+
+type FieldTestMessage_OneofSfixed32 struct {
+	OneofSfixed32 int32 `protobuf:"fixed32,609,opt,name=oneof_sfixed32,json=oneofSfixed32,oneof"`
+}
+
+type FieldTestMessage_OneofFixed32 struct {
+	OneofFixed32 uint32 `protobuf:"fixed32,610,opt,name=oneof_fixed32,json=oneofFixed32,oneof"`
+}
+
+type FieldTestMessage_OneofFloat struct {
+	OneofFloat float32 `protobuf:"fixed32,611,opt,name=oneof_float,json=oneofFloat,oneof"`
+}
+
+type FieldTestMessage_OneofSfixed64 struct {
+	OneofSfixed64 int64 `protobuf:"fixed64,612,opt,name=oneof_sfixed64,json=oneofSfixed64,oneof"`
+}
+
+type FieldTestMessage_OneofFixed64 struct {
+	OneofFixed64 uint64 `protobuf:"fixed64,613,opt,name=oneof_fixed64,json=oneofFixed64,oneof"`
+}
+
+type FieldTestMessage_OneofDouble struct {
+	OneofDouble float64 `protobuf:"fixed64,614,opt,name=oneof_double,json=oneofDouble,oneof"`
+}
+
+type FieldTestMessage_OneofString struct {
+	OneofString string `protobuf:"bytes,615,opt,name=oneof_string,json=oneofString,oneof"`
+}
+
+type FieldTestMessage_OneofBytes struct {
+	OneofBytes []byte `protobuf:"bytes,616,opt,name=oneof_bytes,json=oneofBytes,oneof"`
+}
+
+type FieldTestMessage_Oneof_Message struct {
+	Oneof_Message *FieldTestMessage_Message `protobuf:"bytes,617,opt,name=oneof_Message,json=oneofMessage,oneof"`
+}
+
+type FieldTestMessage_Oneofgroup struct {
+	Oneofgroup *FieldTestMessage_OneofGroup `protobuf:"group,618,opt,name=OneofGroup,json=oneofgroup,oneof"`
+}
+
+type FieldTestMessage_OneofLargestTag struct {
+	OneofLargestTag int32 `protobuf:"varint,536870911,opt,name=oneof_largest_tag,json=oneofLargestTag,oneof"`
+}
+
+func (*FieldTestMessage_OneofBool) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofEnum) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofInt32) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofSint32) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofUint32) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofInt64) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofSint64) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofUint64) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofSfixed32) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofFixed32) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofFloat) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofSfixed64) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofFixed64) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofDouble) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofString) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofBytes) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_Oneof_Message) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_Oneofgroup) isFieldTestMessage_OneofField() {}
+
+func (*FieldTestMessage_OneofLargestTag) isFieldTestMessage_OneofField() {}
+
+type isFieldTestMessage_OneofTwo interface {
+	isFieldTestMessage_OneofTwo()
+}
+
+type FieldTestMessage_OneofTwo_1 struct {
+	OneofTwo_1 int32 `protobuf:"varint,700,opt,name=oneof_two_1,json=oneofTwo1,oneof"`
+}
+
+type FieldTestMessage_OneofTwo_2 struct {
+	OneofTwo_2 int64 `protobuf:"varint,701,opt,name=oneof_two_2,json=oneofTwo2,oneof"`
+}
+
+func (*FieldTestMessage_OneofTwo_1) isFieldTestMessage_OneofTwo() {}
+
+func (*FieldTestMessage_OneofTwo_2) isFieldTestMessage_OneofTwo() {}
+
 type FieldTestMessage_OptionalGroup struct {
 	OptionalGroup        *string  `protobuf:"bytes,19,opt,name=optional_group,json=optionalGroup" json:"optional_group,omitempty"`
 	XXX_NoUnkeyedLiteral struct{} `json:"-"`