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/internal/testprotos/conformance/conformance.pb.go b/internal/testprotos/conformance/conformance.pb.go
index 8c94d06..ee3004d 100644
--- a/internal/testprotos/conformance/conformance.pb.go
+++ b/internal/testprotos/conformance/conformance.pb.go
@@ -215,34 +215,6 @@
 	return xxx_File_conformance_conformance_proto_rawDescGZIP(), []int{1}
 }
 
-type isConformanceRequest_Payload interface {
-	isConformanceRequest_Payload()
-}
-
-type ConformanceRequest_ProtobufPayload struct {
-	ProtobufPayload []byte `protobuf:"bytes,1,opt,name=protobuf_payload,json=protobufPayload,proto3,oneof"`
-}
-
-type ConformanceRequest_JsonPayload struct {
-	JsonPayload string `protobuf:"bytes,2,opt,name=json_payload,json=jsonPayload,proto3,oneof"`
-}
-
-type ConformanceRequest_JspbPayload struct {
-	JspbPayload string `protobuf:"bytes,7,opt,name=jspb_payload,json=jspbPayload,proto3,oneof"`
-}
-
-type ConformanceRequest_TextPayload struct {
-	TextPayload string `protobuf:"bytes,8,opt,name=text_payload,json=textPayload,proto3,oneof"`
-}
-
-func (*ConformanceRequest_ProtobufPayload) isConformanceRequest_Payload() {}
-
-func (*ConformanceRequest_JsonPayload) isConformanceRequest_Payload() {}
-
-func (*ConformanceRequest_JspbPayload) isConformanceRequest_Payload() {}
-
-func (*ConformanceRequest_TextPayload) isConformanceRequest_Payload() {}
-
 func (m *ConformanceRequest) GetPayload() isConformanceRequest_Payload {
 	if m != nil {
 		return m.Payload
@@ -316,6 +288,34 @@
 	}
 }
 
+type isConformanceRequest_Payload interface {
+	isConformanceRequest_Payload()
+}
+
+type ConformanceRequest_ProtobufPayload struct {
+	ProtobufPayload []byte `protobuf:"bytes,1,opt,name=protobuf_payload,json=protobufPayload,proto3,oneof"`
+}
+
+type ConformanceRequest_JsonPayload struct {
+	JsonPayload string `protobuf:"bytes,2,opt,name=json_payload,json=jsonPayload,proto3,oneof"`
+}
+
+type ConformanceRequest_JspbPayload struct {
+	JspbPayload string `protobuf:"bytes,7,opt,name=jspb_payload,json=jspbPayload,proto3,oneof"`
+}
+
+type ConformanceRequest_TextPayload struct {
+	TextPayload string `protobuf:"bytes,8,opt,name=text_payload,json=textPayload,proto3,oneof"`
+}
+
+func (*ConformanceRequest_ProtobufPayload) isConformanceRequest_Payload() {}
+
+func (*ConformanceRequest_JsonPayload) isConformanceRequest_Payload() {}
+
+func (*ConformanceRequest_JspbPayload) isConformanceRequest_Payload() {}
+
+func (*ConformanceRequest_TextPayload) isConformanceRequest_Payload() {}
+
 // Represents a single test case's output.
 type ConformanceResponse struct {
 	// Types that are valid to be assigned to Result:
@@ -378,58 +378,6 @@
 	return xxx_File_conformance_conformance_proto_rawDescGZIP(), []int{2}
 }
 
-type isConformanceResponse_Result interface {
-	isConformanceResponse_Result()
-}
-
-type ConformanceResponse_ParseError struct {
-	ParseError string `protobuf:"bytes,1,opt,name=parse_error,json=parseError,proto3,oneof"`
-}
-
-type ConformanceResponse_SerializeError struct {
-	SerializeError string `protobuf:"bytes,6,opt,name=serialize_error,json=serializeError,proto3,oneof"`
-}
-
-type ConformanceResponse_RuntimeError struct {
-	RuntimeError string `protobuf:"bytes,2,opt,name=runtime_error,json=runtimeError,proto3,oneof"`
-}
-
-type ConformanceResponse_ProtobufPayload struct {
-	ProtobufPayload []byte `protobuf:"bytes,3,opt,name=protobuf_payload,json=protobufPayload,proto3,oneof"`
-}
-
-type ConformanceResponse_JsonPayload struct {
-	JsonPayload string `protobuf:"bytes,4,opt,name=json_payload,json=jsonPayload,proto3,oneof"`
-}
-
-type ConformanceResponse_Skipped struct {
-	Skipped string `protobuf:"bytes,5,opt,name=skipped,proto3,oneof"`
-}
-
-type ConformanceResponse_JspbPayload struct {
-	JspbPayload string `protobuf:"bytes,7,opt,name=jspb_payload,json=jspbPayload,proto3,oneof"`
-}
-
-type ConformanceResponse_TextPayload struct {
-	TextPayload string `protobuf:"bytes,8,opt,name=text_payload,json=textPayload,proto3,oneof"`
-}
-
-func (*ConformanceResponse_ParseError) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_SerializeError) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_RuntimeError) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_ProtobufPayload) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_JsonPayload) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_Skipped) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_JspbPayload) isConformanceResponse_Result() {}
-
-func (*ConformanceResponse_TextPayload) isConformanceResponse_Result() {}
-
 func (m *ConformanceResponse) GetResult() isConformanceResponse_Result {
 	if m != nil {
 		return m.Result
@@ -507,6 +455,58 @@
 	}
 }
 
+type isConformanceResponse_Result interface {
+	isConformanceResponse_Result()
+}
+
+type ConformanceResponse_ParseError struct {
+	ParseError string `protobuf:"bytes,1,opt,name=parse_error,json=parseError,proto3,oneof"`
+}
+
+type ConformanceResponse_SerializeError struct {
+	SerializeError string `protobuf:"bytes,6,opt,name=serialize_error,json=serializeError,proto3,oneof"`
+}
+
+type ConformanceResponse_RuntimeError struct {
+	RuntimeError string `protobuf:"bytes,2,opt,name=runtime_error,json=runtimeError,proto3,oneof"`
+}
+
+type ConformanceResponse_ProtobufPayload struct {
+	ProtobufPayload []byte `protobuf:"bytes,3,opt,name=protobuf_payload,json=protobufPayload,proto3,oneof"`
+}
+
+type ConformanceResponse_JsonPayload struct {
+	JsonPayload string `protobuf:"bytes,4,opt,name=json_payload,json=jsonPayload,proto3,oneof"`
+}
+
+type ConformanceResponse_Skipped struct {
+	Skipped string `protobuf:"bytes,5,opt,name=skipped,proto3,oneof"`
+}
+
+type ConformanceResponse_JspbPayload struct {
+	JspbPayload string `protobuf:"bytes,7,opt,name=jspb_payload,json=jspbPayload,proto3,oneof"`
+}
+
+type ConformanceResponse_TextPayload struct {
+	TextPayload string `protobuf:"bytes,8,opt,name=text_payload,json=textPayload,proto3,oneof"`
+}
+
+func (*ConformanceResponse_ParseError) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_SerializeError) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_RuntimeError) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_ProtobufPayload) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_JsonPayload) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_Skipped) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_JspbPayload) isConformanceResponse_Result() {}
+
+func (*ConformanceResponse_TextPayload) isConformanceResponse_Result() {}
+
 // Encoding options for jspb format.
 type JspbEncodingConfig struct {
 	// Encode the value field of Any as jspb array if ture, otherwise binary.
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index e6cd19b..0ac6b8e 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -900,64 +900,6 @@
 	return Default_TestAllTypes_DefaultForeignEnum
 }
 
-type isTestAllTypes_OneofField interface {
-	isTestAllTypes_OneofField()
-}
-
-type TestAllTypes_OneofUint32 struct {
-	OneofUint32 uint32 `protobuf:"varint,111,opt,name=oneof_uint32,json=oneofUint32,oneof"`
-}
-
-type TestAllTypes_OneofNestedMessage struct {
-	OneofNestedMessage *TestAllTypes_NestedMessage `protobuf:"bytes,112,opt,name=oneof_nested_message,json=oneofNestedMessage,oneof"`
-}
-
-type TestAllTypes_OneofString struct {
-	OneofString string `protobuf:"bytes,113,opt,name=oneof_string,json=oneofString,oneof"`
-}
-
-type TestAllTypes_OneofBytes struct {
-	OneofBytes []byte `protobuf:"bytes,114,opt,name=oneof_bytes,json=oneofBytes,oneof"`
-}
-
-type TestAllTypes_OneofBool struct {
-	OneofBool bool `protobuf:"varint,115,opt,name=oneof_bool,json=oneofBool,oneof"`
-}
-
-type TestAllTypes_OneofUint64 struct {
-	OneofUint64 uint64 `protobuf:"varint,116,opt,name=oneof_uint64,json=oneofUint64,oneof"`
-}
-
-type TestAllTypes_OneofFloat struct {
-	OneofFloat float32 `protobuf:"fixed32,117,opt,name=oneof_float,json=oneofFloat,oneof"`
-}
-
-type TestAllTypes_OneofDouble struct {
-	OneofDouble float64 `protobuf:"fixed64,118,opt,name=oneof_double,json=oneofDouble,oneof"`
-}
-
-type TestAllTypes_OneofEnum struct {
-	OneofEnum TestAllTypes_NestedEnum `protobuf:"varint,119,opt,name=oneof_enum,json=oneofEnum,enum=goproto.proto.test.TestAllTypes_NestedEnum,oneof"`
-}
-
-func (*TestAllTypes_OneofUint32) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofNestedMessage) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofString) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofBytes) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofBool) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofUint64) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofFloat) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofDouble) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofEnum) isTestAllTypes_OneofField() {}
-
 func (m *TestAllTypes) GetOneofField() isTestAllTypes_OneofField {
 	if m != nil {
 		return m.OneofField
@@ -1043,6 +985,64 @@
 	}
 }
 
+type isTestAllTypes_OneofField interface {
+	isTestAllTypes_OneofField()
+}
+
+type TestAllTypes_OneofUint32 struct {
+	OneofUint32 uint32 `protobuf:"varint,111,opt,name=oneof_uint32,json=oneofUint32,oneof"`
+}
+
+type TestAllTypes_OneofNestedMessage struct {
+	OneofNestedMessage *TestAllTypes_NestedMessage `protobuf:"bytes,112,opt,name=oneof_nested_message,json=oneofNestedMessage,oneof"`
+}
+
+type TestAllTypes_OneofString struct {
+	OneofString string `protobuf:"bytes,113,opt,name=oneof_string,json=oneofString,oneof"`
+}
+
+type TestAllTypes_OneofBytes struct {
+	OneofBytes []byte `protobuf:"bytes,114,opt,name=oneof_bytes,json=oneofBytes,oneof"`
+}
+
+type TestAllTypes_OneofBool struct {
+	OneofBool bool `protobuf:"varint,115,opt,name=oneof_bool,json=oneofBool,oneof"`
+}
+
+type TestAllTypes_OneofUint64 struct {
+	OneofUint64 uint64 `protobuf:"varint,116,opt,name=oneof_uint64,json=oneofUint64,oneof"`
+}
+
+type TestAllTypes_OneofFloat struct {
+	OneofFloat float32 `protobuf:"fixed32,117,opt,name=oneof_float,json=oneofFloat,oneof"`
+}
+
+type TestAllTypes_OneofDouble struct {
+	OneofDouble float64 `protobuf:"fixed64,118,opt,name=oneof_double,json=oneofDouble,oneof"`
+}
+
+type TestAllTypes_OneofEnum struct {
+	OneofEnum TestAllTypes_NestedEnum `protobuf:"varint,119,opt,name=oneof_enum,json=oneofEnum,enum=goproto.proto.test.TestAllTypes_NestedEnum,oneof"`
+}
+
+func (*TestAllTypes_OneofUint32) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofNestedMessage) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofString) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofBytes) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofBool) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofUint64) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofFloat) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofDouble) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofEnum) isTestAllTypes_OneofField() {}
+
 // Deprecated: Do not use.
 type TestDeprecatedMessage struct {
 	DeprecatedInt32 *int32 `protobuf:"varint,1,opt,name=deprecated_int32,json=deprecatedInt32" json:"deprecated_int32,omitempty"` // Deprecated: Do not use.
@@ -1085,16 +1085,6 @@
 	return 0
 }
 
-type isTestDeprecatedMessage_DeprecatedOneof interface {
-	isTestDeprecatedMessage_DeprecatedOneof()
-}
-
-type TestDeprecatedMessage_DeprecatedOneofField struct {
-	DeprecatedOneofField int32 `protobuf:"varint,2,opt,name=deprecated_oneof_field,json=deprecatedOneofField,oneof"`
-}
-
-func (*TestDeprecatedMessage_DeprecatedOneofField) isTestDeprecatedMessage_DeprecatedOneof() {}
-
 func (m *TestDeprecatedMessage) GetDeprecatedOneof() isTestDeprecatedMessage_DeprecatedOneof {
 	if m != nil {
 		return m.DeprecatedOneof
@@ -1117,6 +1107,16 @@
 	}
 }
 
+type isTestDeprecatedMessage_DeprecatedOneof interface {
+	isTestDeprecatedMessage_DeprecatedOneof()
+}
+
+type TestDeprecatedMessage_DeprecatedOneofField struct {
+	DeprecatedOneofField int32 `protobuf:"varint,2,opt,name=deprecated_oneof_field,json=deprecatedOneofField,oneof"`
+}
+
+func (*TestDeprecatedMessage_DeprecatedOneofField) isTestDeprecatedMessage_DeprecatedOneof() {}
+
 type ForeignMessage struct {
 	C                    *int32   `protobuf:"varint,1,opt,name=c" json:"c,omitempty"`
 	D                    *int32   `protobuf:"varint,2,opt,name=d" json:"d,omitempty"`
diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
index ad26119..2b5379e 100644
--- a/internal/testprotos/test3/test.pb.go
+++ b/internal/testprotos/test3/test.pb.go
@@ -609,64 +609,6 @@
 	return nil
 }
 
-type isTestAllTypes_OneofField interface {
-	isTestAllTypes_OneofField()
-}
-
-type TestAllTypes_OneofUint32 struct {
-	OneofUint32 uint32 `protobuf:"varint,111,opt,name=oneof_uint32,json=oneofUint32,proto3,oneof"`
-}
-
-type TestAllTypes_OneofNestedMessage struct {
-	OneofNestedMessage *TestAllTypes_NestedMessage `protobuf:"bytes,112,opt,name=oneof_nested_message,json=oneofNestedMessage,proto3,oneof"`
-}
-
-type TestAllTypes_OneofString struct {
-	OneofString string `protobuf:"bytes,113,opt,name=oneof_string,json=oneofString,proto3,oneof"`
-}
-
-type TestAllTypes_OneofBytes struct {
-	OneofBytes []byte `protobuf:"bytes,114,opt,name=oneof_bytes,json=oneofBytes,proto3,oneof"`
-}
-
-type TestAllTypes_OneofBool struct {
-	OneofBool bool `protobuf:"varint,115,opt,name=oneof_bool,json=oneofBool,proto3,oneof"`
-}
-
-type TestAllTypes_OneofUint64 struct {
-	OneofUint64 uint64 `protobuf:"varint,116,opt,name=oneof_uint64,json=oneofUint64,proto3,oneof"`
-}
-
-type TestAllTypes_OneofFloat struct {
-	OneofFloat float32 `protobuf:"fixed32,117,opt,name=oneof_float,json=oneofFloat,proto3,oneof"`
-}
-
-type TestAllTypes_OneofDouble struct {
-	OneofDouble float64 `protobuf:"fixed64,118,opt,name=oneof_double,json=oneofDouble,proto3,oneof"`
-}
-
-type TestAllTypes_OneofEnum struct {
-	OneofEnum TestAllTypes_NestedEnum `protobuf:"varint,119,opt,name=oneof_enum,json=oneofEnum,proto3,enum=goproto.proto.test3.TestAllTypes_NestedEnum,oneof"`
-}
-
-func (*TestAllTypes_OneofUint32) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofNestedMessage) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofString) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofBytes) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofBool) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofUint64) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofFloat) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofDouble) isTestAllTypes_OneofField() {}
-
-func (*TestAllTypes_OneofEnum) isTestAllTypes_OneofField() {}
-
 func (m *TestAllTypes) GetOneofField() isTestAllTypes_OneofField {
 	if m != nil {
 		return m.OneofField
@@ -752,6 +694,64 @@
 	}
 }
 
+type isTestAllTypes_OneofField interface {
+	isTestAllTypes_OneofField()
+}
+
+type TestAllTypes_OneofUint32 struct {
+	OneofUint32 uint32 `protobuf:"varint,111,opt,name=oneof_uint32,json=oneofUint32,proto3,oneof"`
+}
+
+type TestAllTypes_OneofNestedMessage struct {
+	OneofNestedMessage *TestAllTypes_NestedMessage `protobuf:"bytes,112,opt,name=oneof_nested_message,json=oneofNestedMessage,proto3,oneof"`
+}
+
+type TestAllTypes_OneofString struct {
+	OneofString string `protobuf:"bytes,113,opt,name=oneof_string,json=oneofString,proto3,oneof"`
+}
+
+type TestAllTypes_OneofBytes struct {
+	OneofBytes []byte `protobuf:"bytes,114,opt,name=oneof_bytes,json=oneofBytes,proto3,oneof"`
+}
+
+type TestAllTypes_OneofBool struct {
+	OneofBool bool `protobuf:"varint,115,opt,name=oneof_bool,json=oneofBool,proto3,oneof"`
+}
+
+type TestAllTypes_OneofUint64 struct {
+	OneofUint64 uint64 `protobuf:"varint,116,opt,name=oneof_uint64,json=oneofUint64,proto3,oneof"`
+}
+
+type TestAllTypes_OneofFloat struct {
+	OneofFloat float32 `protobuf:"fixed32,117,opt,name=oneof_float,json=oneofFloat,proto3,oneof"`
+}
+
+type TestAllTypes_OneofDouble struct {
+	OneofDouble float64 `protobuf:"fixed64,118,opt,name=oneof_double,json=oneofDouble,proto3,oneof"`
+}
+
+type TestAllTypes_OneofEnum struct {
+	OneofEnum TestAllTypes_NestedEnum `protobuf:"varint,119,opt,name=oneof_enum,json=oneofEnum,proto3,enum=goproto.proto.test3.TestAllTypes_NestedEnum,oneof"`
+}
+
+func (*TestAllTypes_OneofUint32) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofNestedMessage) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofString) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofBytes) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofBool) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofUint64) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofFloat) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofDouble) isTestAllTypes_OneofField() {}
+
+func (*TestAllTypes_OneofEnum) isTestAllTypes_OneofField() {}
+
 type ForeignMessage struct {
 	C                    int32    `protobuf:"varint,1,opt,name=c,proto3" json:"c,omitempty"`
 	D                    int32    `protobuf:"varint,2,opt,name=d,proto3" json:"d,omitempty"`