cmd/protoc-gen-go: remove generation of XXX_OneofWrappers

Associate the oneof wrapper types with a message by conveying that
information to the associated MessageInfo.

Change-Id: Iabfca593850e1d6a89498a37eacbf22dbb73bd20
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/185239
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/conformance/conformance.pb.go b/internal/testprotos/conformance/conformance.pb.go
index a053a9a..ec9ddc6 100644
--- a/internal/testprotos/conformance/conformance.pb.go
+++ b/internal/testprotos/conformance/conformance.pb.go
@@ -291,16 +291,6 @@
 	return nil
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*ConformanceRequest) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*ConformanceRequest_ProtobufPayload)(nil),
-		(*ConformanceRequest_JsonPayload)(nil),
-		(*ConformanceRequest_JspbPayload)(nil),
-		(*ConformanceRequest_TextPayload)(nil),
-	}
-}
-
 type isConformanceRequest_Payload interface {
 	isConformanceRequest_Payload()
 }
@@ -454,20 +444,6 @@
 	return ""
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*ConformanceResponse) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*ConformanceResponse_ParseError)(nil),
-		(*ConformanceResponse_SerializeError)(nil),
-		(*ConformanceResponse_RuntimeError)(nil),
-		(*ConformanceResponse_ProtobufPayload)(nil),
-		(*ConformanceResponse_JsonPayload)(nil),
-		(*ConformanceResponse_Skipped)(nil),
-		(*ConformanceResponse_JspbPayload)(nil),
-		(*ConformanceResponse_TextPayload)(nil),
-	}
-}
-
 type isConformanceResponse_Result interface {
 	isConformanceResponse_Result()
 }
@@ -683,6 +659,22 @@
 	if File_conformance_conformance_proto != nil {
 		return
 	}
+	file_conformance_conformance_proto_msgTypes[1].OneofWrappers = []interface{}{
+		(*ConformanceRequest_ProtobufPayload)(nil),
+		(*ConformanceRequest_JsonPayload)(nil),
+		(*ConformanceRequest_JspbPayload)(nil),
+		(*ConformanceRequest_TextPayload)(nil),
+	}
+	file_conformance_conformance_proto_msgTypes[2].OneofWrappers = []interface{}{
+		(*ConformanceResponse_ParseError)(nil),
+		(*ConformanceResponse_SerializeError)(nil),
+		(*ConformanceResponse_RuntimeError)(nil),
+		(*ConformanceResponse_ProtobufPayload)(nil),
+		(*ConformanceResponse_JsonPayload)(nil),
+		(*ConformanceResponse_Skipped)(nil),
+		(*ConformanceResponse_JspbPayload)(nil),
+		(*ConformanceResponse_TextPayload)(nil),
+	}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{
 			RawDescriptor: file_conformance_conformance_proto_rawDesc,
diff --git a/internal/testprotos/conformance/test_messages_proto2.pb.go b/internal/testprotos/conformance/test_messages_proto2.pb.go
index 00b6682..928e5b2 100644
--- a/internal/testprotos/conformance/test_messages_proto2.pb.go
+++ b/internal/testprotos/conformance/test_messages_proto2.pb.go
@@ -907,21 +907,6 @@
 	return 0
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*TestAllTypesProto2) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*TestAllTypesProto2_OneofUint32)(nil),
-		(*TestAllTypesProto2_OneofNestedMessage)(nil),
-		(*TestAllTypesProto2_OneofString)(nil),
-		(*TestAllTypesProto2_OneofBytes)(nil),
-		(*TestAllTypesProto2_OneofBool)(nil),
-		(*TestAllTypesProto2_OneofUint64)(nil),
-		(*TestAllTypesProto2_OneofFloat)(nil),
-		(*TestAllTypesProto2_OneofDouble)(nil),
-		(*TestAllTypesProto2_OneofEnum)(nil),
-	}
-}
-
 type isTestAllTypesProto2_OneofField interface {
 	isTestAllTypesProto2_OneofField()
 }
@@ -1902,6 +1887,17 @@
 	if File_google_protobuf_test_messages_proto2_proto != nil {
 		return
 	}
+	file_google_protobuf_test_messages_proto2_proto_msgTypes[0].OneofWrappers = []interface{}{
+		(*TestAllTypesProto2_OneofUint32)(nil),
+		(*TestAllTypesProto2_OneofNestedMessage)(nil),
+		(*TestAllTypesProto2_OneofString)(nil),
+		(*TestAllTypesProto2_OneofBytes)(nil),
+		(*TestAllTypesProto2_OneofBool)(nil),
+		(*TestAllTypesProto2_OneofUint64)(nil),
+		(*TestAllTypesProto2_OneofFloat)(nil),
+		(*TestAllTypesProto2_OneofDouble)(nil),
+		(*TestAllTypesProto2_OneofEnum)(nil),
+	}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{
 			RawDescriptor: file_google_protobuf_test_messages_proto2_proto_rawDesc,
diff --git a/internal/testprotos/conformance/test_messages_proto3.pb.go b/internal/testprotos/conformance/test_messages_proto3.pb.go
index 75bc2c0..29f92bc 100644
--- a/internal/testprotos/conformance/test_messages_proto3.pb.go
+++ b/internal/testprotos/conformance/test_messages_proto3.pb.go
@@ -1184,21 +1184,6 @@
 	return 0
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*TestAllTypesProto3) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*TestAllTypesProto3_OneofUint32)(nil),
-		(*TestAllTypesProto3_OneofNestedMessage)(nil),
-		(*TestAllTypesProto3_OneofString)(nil),
-		(*TestAllTypesProto3_OneofBytes)(nil),
-		(*TestAllTypesProto3_OneofBool)(nil),
-		(*TestAllTypesProto3_OneofUint64)(nil),
-		(*TestAllTypesProto3_OneofFloat)(nil),
-		(*TestAllTypesProto3_OneofDouble)(nil),
-		(*TestAllTypesProto3_OneofEnum)(nil),
-	}
-}
-
 type isTestAllTypesProto3_OneofField interface {
 	isTestAllTypesProto3_OneofField()
 }
@@ -2148,6 +2133,17 @@
 	if File_google_protobuf_test_messages_proto3_proto != nil {
 		return
 	}
+	file_google_protobuf_test_messages_proto3_proto_msgTypes[0].OneofWrappers = []interface{}{
+		(*TestAllTypesProto3_OneofUint32)(nil),
+		(*TestAllTypesProto3_OneofNestedMessage)(nil),
+		(*TestAllTypesProto3_OneofString)(nil),
+		(*TestAllTypesProto3_OneofBytes)(nil),
+		(*TestAllTypesProto3_OneofBool)(nil),
+		(*TestAllTypesProto3_OneofUint64)(nil),
+		(*TestAllTypesProto3_OneofFloat)(nil),
+		(*TestAllTypesProto3_OneofDouble)(nil),
+		(*TestAllTypesProto3_OneofEnum)(nil),
+	}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{
 			RawDescriptor: file_google_protobuf_test_messages_proto3_proto_rawDesc,
diff --git a/internal/testprotos/irregular/test.pb.go b/internal/testprotos/irregular/test.pb.go
index 93092dc..c8ef2c4 100644
--- a/internal/testprotos/irregular/test.pb.go
+++ b/internal/testprotos/irregular/test.pb.go
@@ -95,13 +95,6 @@
 	return nil
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*Message) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*Message_OneofMessage)(nil),
-	}
-}
-
 type isMessage_Union interface {
 	isMessage_Union()
 }
@@ -198,6 +191,9 @@
 		return
 	}
 	file_irregular_irregular_proto_init()
+	file_irregular_test_proto_msgTypes[0].OneofWrappers = []interface{}{
+		(*Message_OneofMessage)(nil),
+	}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{
 			RawDescriptor: file_irregular_test_proto_rawDesc,
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index 359f459..9fa7865 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -976,21 +976,6 @@
 	return TestAllTypes_FOO
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*TestAllTypes) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*TestAllTypes_OneofUint32)(nil),
-		(*TestAllTypes_OneofNestedMessage)(nil),
-		(*TestAllTypes_OneofString)(nil),
-		(*TestAllTypes_OneofBytes)(nil),
-		(*TestAllTypes_OneofBool)(nil),
-		(*TestAllTypes_OneofUint64)(nil),
-		(*TestAllTypes_OneofFloat)(nil),
-		(*TestAllTypes_OneofDouble)(nil),
-		(*TestAllTypes_OneofEnum)(nil),
-	}
-}
-
 type isTestAllTypes_OneofField interface {
 	isTestAllTypes_OneofField()
 }
@@ -1106,13 +1091,6 @@
 	return 0
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*TestDeprecatedMessage) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*TestDeprecatedMessage_DeprecatedOneofField)(nil),
-	}
-}
-
 type isTestDeprecatedMessage_DeprecatedOneof interface {
 	isTestDeprecatedMessage_DeprecatedOneof()
 }
@@ -1446,13 +1424,6 @@
 	return nil
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*TestRequiredForeign) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*TestRequiredForeign_OneofMessage)(nil),
-	}
-}
-
 type isTestRequiredForeign_OneofField interface {
 	isTestRequiredForeign_OneofField()
 }
@@ -3504,6 +3475,23 @@
 	}
 	file_test_test_import_proto_init()
 	file_test_test_public_proto_init()
+	file_test_test_proto_msgTypes[0].OneofWrappers = []interface{}{
+		(*TestAllTypes_OneofUint32)(nil),
+		(*TestAllTypes_OneofNestedMessage)(nil),
+		(*TestAllTypes_OneofString)(nil),
+		(*TestAllTypes_OneofBytes)(nil),
+		(*TestAllTypes_OneofBool)(nil),
+		(*TestAllTypes_OneofUint64)(nil),
+		(*TestAllTypes_OneofFloat)(nil),
+		(*TestAllTypes_OneofDouble)(nil),
+		(*TestAllTypes_OneofEnum)(nil),
+	}
+	file_test_test_proto_msgTypes[1].OneofWrappers = []interface{}{
+		(*TestDeprecatedMessage_DeprecatedOneofField)(nil),
+	}
+	file_test_test_proto_msgTypes[9].OneofWrappers = []interface{}{
+		(*TestRequiredForeign_OneofMessage)(nil),
+	}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{
 			RawDescriptor: file_test_test_proto_rawDesc,
diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
index a8cb2bc..67007b7 100644
--- a/internal/testprotos/test3/test.pb.go
+++ b/internal/testprotos/test3/test.pb.go
@@ -692,21 +692,6 @@
 	return TestAllTypes_FOO
 }
 
-// XXX_OneofWrappers is for the internal use of the proto package.
-func (*TestAllTypes) XXX_OneofWrappers() []interface{} {
-	return []interface{}{
-		(*TestAllTypes_OneofUint32)(nil),
-		(*TestAllTypes_OneofNestedMessage)(nil),
-		(*TestAllTypes_OneofString)(nil),
-		(*TestAllTypes_OneofBytes)(nil),
-		(*TestAllTypes_OneofBool)(nil),
-		(*TestAllTypes_OneofUint64)(nil),
-		(*TestAllTypes_OneofFloat)(nil),
-		(*TestAllTypes_OneofDouble)(nil),
-		(*TestAllTypes_OneofEnum)(nil),
-	}
-}
-
 type isTestAllTypes_OneofField interface {
 	isTestAllTypes_OneofField()
 }
@@ -1337,6 +1322,17 @@
 		return
 	}
 	file_test3_test_import_proto_init()
+	file_test3_test_proto_msgTypes[0].OneofWrappers = []interface{}{
+		(*TestAllTypes_OneofUint32)(nil),
+		(*TestAllTypes_OneofNestedMessage)(nil),
+		(*TestAllTypes_OneofString)(nil),
+		(*TestAllTypes_OneofBytes)(nil),
+		(*TestAllTypes_OneofBool)(nil),
+		(*TestAllTypes_OneofUint64)(nil),
+		(*TestAllTypes_OneofFloat)(nil),
+		(*TestAllTypes_OneofDouble)(nil),
+		(*TestAllTypes_OneofEnum)(nil),
+	}
 	out := protoimpl.TypeBuilder{
 		File: protoimpl.DescBuilder{
 			RawDescriptor: file_test3_test_proto_rawDesc,