cmd/protoc-gen-go: used named types for special fields

Using a named fields gives us the flexibility to change the underlying
representation of special fields without needing to regenerate user code.

We add a named type for ExtensionFields, UnknownFields, and SizeCache.

Change-Id: I107cf82899850ea76665310ce79def60f0f7ab97
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/172402
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/testprotos/conformance/conformance.pb.go b/internal/testprotos/conformance/conformance.pb.go
index 51ea491..1bd4725 100644
--- a/internal/testprotos/conformance/conformance.pb.go
+++ b/internal/testprotos/conformance/conformance.pb.go
@@ -118,10 +118,10 @@
 // This will be known by message_type == "conformance.FailureSet", a conformance
 // test should return a serialized FailureSet in protobuf_payload.
 type FailureSet struct {
-	Failure              []string `protobuf:"bytes,1,rep,name=failure,proto3" json:"failure,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	Failure              []string                `protobuf:"bytes,1,rep,name=failure,proto3" json:"failure,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *FailureSet) Reset() {
@@ -186,10 +186,10 @@
 	// for more information.
 	TestCategory TestCategory `protobuf:"varint,5,opt,name=test_category,json=testCategory,proto3,enum=conformance.TestCategory" json:"test_category,omitempty"`
 	// Specify details for how to encode jspb.
-	JspbEncodingOptions  *JspbEncodingConfig `protobuf:"bytes,6,opt,name=jspb_encoding_options,json=jspbEncodingOptions,proto3" json:"jspb_encoding_options,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}            `json:"-"`
-	XXX_unrecognized     []byte              `json:"-"`
-	XXX_sizecache        int32               `json:"-"`
+	JspbEncodingOptions  *JspbEncodingConfig     `protobuf:"bytes,6,opt,name=jspb_encoding_options,json=jspbEncodingOptions,proto3" json:"jspb_encoding_options,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *ConformanceRequest) Reset() {
@@ -351,8 +351,8 @@
 	//	*ConformanceResponse_TextPayload
 	Result               isConformanceResponse_Result `protobuf_oneof:"result"`
 	XXX_NoUnkeyedLiteral struct{}                     `json:"-"`
-	XXX_unrecognized     []byte                       `json:"-"`
-	XXX_sizecache        int32                        `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields      `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache          `json:"-"`
 }
 
 func (x *ConformanceResponse) Reset() {
@@ -510,10 +510,10 @@
 // Encoding options for jspb format.
 type JspbEncodingConfig struct {
 	// Encode the value field of Any as jspb array if ture, otherwise binary.
-	UseJspbArrayAnyFormat bool     `protobuf:"varint,1,opt,name=use_jspb_array_any_format,json=useJspbArrayAnyFormat,proto3" json:"use_jspb_array_any_format,omitempty"`
-	XXX_NoUnkeyedLiteral  struct{} `json:"-"`
-	XXX_unrecognized      []byte   `json:"-"`
-	XXX_sizecache         int32    `json:"-"`
+	UseJspbArrayAnyFormat bool                    `protobuf:"varint,1,opt,name=use_jspb_array_any_format,json=useJspbArrayAnyFormat,proto3" json:"use_jspb_array_any_format,omitempty"`
+	XXX_NoUnkeyedLiteral  struct{}                `json:"-"`
+	XXX_unrecognized      protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache         protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *JspbEncodingConfig) Reset() {
diff --git a/internal/testprotos/legacy/legacy.pb.go b/internal/testprotos/legacy/legacy.pb.go
index dfea835..cc3dbc1 100644
--- a/internal/testprotos/legacy/legacy.pb.go
+++ b/internal/testprotos/legacy/legacy.pb.go
@@ -26,21 +26,21 @@
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
 type Legacy struct {
-	F1                   *proto2_v0_0.Message  `protobuf:"bytes,1,opt,name=f1,proto3" json:"f1,omitempty"`
-	F2                   *proto3_v0_0.Message  `protobuf:"bytes,2,opt,name=f2,proto3" json:"f2,omitempty"`
-	F3                   *proto2_v0_01.Message `protobuf:"bytes,3,opt,name=f3,proto3" json:"f3,omitempty"`
-	F4                   *proto3_v0_01.Message `protobuf:"bytes,4,opt,name=f4,proto3" json:"f4,omitempty"`
-	F5                   *proto2_v1_0.Message  `protobuf:"bytes,5,opt,name=f5,proto3" json:"f5,omitempty"`
-	F6                   *proto3_v1_0.Message  `protobuf:"bytes,6,opt,name=f6,proto3" json:"f6,omitempty"`
-	F7                   *proto2_v1_1.Message  `protobuf:"bytes,7,opt,name=f7,proto3" json:"f7,omitempty"`
-	F8                   *proto3_v1_1.Message  `protobuf:"bytes,8,opt,name=f8,proto3" json:"f8,omitempty"`
-	F9                   *proto2_v1_2.Message  `protobuf:"bytes,9,opt,name=f9,proto3" json:"f9,omitempty"`
-	F10                  *proto3_v1_2.Message  `protobuf:"bytes,10,opt,name=f10,proto3" json:"f10,omitempty"`
-	F11                  *proto2_v1_21.Message `protobuf:"bytes,11,opt,name=f11,proto3" json:"f11,omitempty"`
-	F12                  *proto3_v1_21.Message `protobuf:"bytes,12,opt,name=f12,proto3" json:"f12,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}              `json:"-"`
-	XXX_unrecognized     []byte                `json:"-"`
-	XXX_sizecache        int32                 `json:"-"`
+	F1                   *proto2_v0_0.Message    `protobuf:"bytes,1,opt,name=f1,proto3" json:"f1,omitempty"`
+	F2                   *proto3_v0_0.Message    `protobuf:"bytes,2,opt,name=f2,proto3" json:"f2,omitempty"`
+	F3                   *proto2_v0_01.Message   `protobuf:"bytes,3,opt,name=f3,proto3" json:"f3,omitempty"`
+	F4                   *proto3_v0_01.Message   `protobuf:"bytes,4,opt,name=f4,proto3" json:"f4,omitempty"`
+	F5                   *proto2_v1_0.Message    `protobuf:"bytes,5,opt,name=f5,proto3" json:"f5,omitempty"`
+	F6                   *proto3_v1_0.Message    `protobuf:"bytes,6,opt,name=f6,proto3" json:"f6,omitempty"`
+	F7                   *proto2_v1_1.Message    `protobuf:"bytes,7,opt,name=f7,proto3" json:"f7,omitempty"`
+	F8                   *proto3_v1_1.Message    `protobuf:"bytes,8,opt,name=f8,proto3" json:"f8,omitempty"`
+	F9                   *proto2_v1_2.Message    `protobuf:"bytes,9,opt,name=f9,proto3" json:"f9,omitempty"`
+	F10                  *proto3_v1_2.Message    `protobuf:"bytes,10,opt,name=f10,proto3" json:"f10,omitempty"`
+	F11                  *proto2_v1_21.Message   `protobuf:"bytes,11,opt,name=f11,proto3" json:"f11,omitempty"`
+	F12                  *proto3_v1_21.Message   `protobuf:"bytes,12,opt,name=f12,proto3" json:"f12,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *Legacy) Reset() {
diff --git a/internal/testprotos/test/test.pb.go b/internal/testprotos/test/test.pb.go
index 6eb43c8..263dd3a 100644
--- a/internal/testprotos/test/test.pb.go
+++ b/internal/testprotos/test/test.pb.go
@@ -315,8 +315,8 @@
 	//	*TestAllTypes_OneofEnum
 	OneofField           isTestAllTypes_OneofField `protobuf_oneof:"oneof_field"`
 	XXX_NoUnkeyedLiteral struct{}                  `json:"-"`
-	XXX_unrecognized     []byte                    `json:"-"`
-	XXX_sizecache        int32                     `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields   `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache       `json:"-"`
 }
 
 func (x *TestAllTypes) Reset() {
@@ -1058,8 +1058,8 @@
 	//	*TestDeprecatedMessage_DeprecatedOneofField
 	DeprecatedOneof      isTestDeprecatedMessage_DeprecatedOneof `protobuf_oneof:"deprecated_oneof"`
 	XXX_NoUnkeyedLiteral struct{}                                `json:"-"`
-	XXX_unrecognized     []byte                                  `json:"-"`
-	XXX_sizecache        int32                                   `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields                 `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache                     `json:"-"`
 }
 
 func (x *TestDeprecatedMessage) Reset() {
@@ -1126,11 +1126,11 @@
 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"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	C                    *int32                  `protobuf:"varint,1,opt,name=c" json:"c,omitempty"`
+	D                    *int32                  `protobuf:"varint,2,opt,name=d" json:"d,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *ForeignMessage) Reset() {
@@ -1171,9 +1171,9 @@
 }
 
 type TestReservedFields struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestReservedFields) Reset() {
@@ -1200,10 +1200,10 @@
 }
 
 type TestAllExtensions struct {
-	XXX_NoUnkeyedLiteral   struct{}                    `json:"-"`
-	XXX_InternalExtensions protoimpl.ExtensionFieldsV1 `json:"-"`
-	XXX_unrecognized       []byte                      `json:"-"`
-	XXX_sizecache          int32                       `json:"-"`
+	XXX_NoUnkeyedLiteral   struct{}                  `json:"-"`
+	XXX_InternalExtensions protoimpl.ExtensionFields `json:"-"`
+	XXX_unrecognized       protoimpl.UnknownFields   `json:"-"`
+	XXX_sizecache          protoimpl.SizeCache       `json:"-"`
 }
 
 func (x *TestAllExtensions) Reset() {
@@ -1239,10 +1239,10 @@
 }
 
 type OptionalGroupExtension struct {
-	A                    *int32   `protobuf:"varint,17,opt,name=a" json:"a,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	A                    *int32                  `protobuf:"varint,17,opt,name=a" json:"a,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *OptionalGroupExtension) Reset() {
@@ -1276,10 +1276,10 @@
 }
 
 type RepeatedGroupExtension struct {
-	A                    *int32   `protobuf:"varint,47,opt,name=a" json:"a,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	A                    *int32                  `protobuf:"varint,47,opt,name=a" json:"a,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *RepeatedGroupExtension) Reset() {
@@ -1313,9 +1313,9 @@
 }
 
 type TestNestedExtension struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestNestedExtension) Reset() {
@@ -1342,10 +1342,10 @@
 }
 
 type TestRequired struct {
-	RequiredField        *int32   `protobuf:"varint,1,req,name=required_field,json=requiredField" json:"required_field,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	RequiredField        *int32                  `protobuf:"varint,1,req,name=required_field,json=requiredField" json:"required_field,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestRequired) Reset() {
@@ -1383,8 +1383,8 @@
 	RepeatedMessage      []*TestRequired         `protobuf:"bytes,2,rep,name=repeated_message,json=repeatedMessage" json:"repeated_message,omitempty"`
 	MapMessage           map[int32]*TestRequired `protobuf:"bytes,3,rep,name=map_message,json=mapMessage" json:"map_message,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
 	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
-	XXX_unrecognized     []byte                  `json:"-"`
-	XXX_sizecache        int32                   `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestRequiredForeign) Reset() {
@@ -1435,8 +1435,8 @@
 	Optionalgroup        *TestRequiredGroupFields_OptionalGroup   `protobuf:"group,1,opt,name=OptionalGroup,json=optionalgroup" json:"optionalgroup,omitempty"`
 	Repeatedgroup        []*TestRequiredGroupFields_RepeatedGroup `protobuf:"group,3,rep,name=RepeatedGroup,json=repeatedgroup" json:"repeatedgroup,omitempty"`
 	XXX_NoUnkeyedLiteral struct{}                                 `json:"-"`
-	XXX_unrecognized     []byte                                   `json:"-"`
-	XXX_sizecache        int32                                    `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields                  `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache                      `json:"-"`
 }
 
 func (x *TestRequiredGroupFields) Reset() {
@@ -1478,9 +1478,9 @@
 
 // Test that RPC services work.
 type FooRequest struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *FooRequest) Reset() {
@@ -1507,9 +1507,9 @@
 }
 
 type FooResponse struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *FooResponse) Reset() {
@@ -1536,11 +1536,11 @@
 }
 
 type TestAllTypes_NestedMessage struct {
-	A                    *int32        `protobuf:"varint,1,opt,name=a" json:"a,omitempty"`
-	Corecursive          *TestAllTypes `protobuf:"bytes,2,opt,name=corecursive" json:"corecursive,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
-	XXX_unrecognized     []byte        `json:"-"`
-	XXX_sizecache        int32         `json:"-"`
+	A                    *int32                  `protobuf:"varint,1,opt,name=a" json:"a,omitempty"`
+	Corecursive          *TestAllTypes           `protobuf:"bytes,2,opt,name=corecursive" json:"corecursive,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestAllTypes_NestedMessage) Reset() {
@@ -1581,10 +1581,10 @@
 }
 
 type TestAllTypes_OptionalGroup struct {
-	A                    *int32   `protobuf:"varint,17,opt,name=a" json:"a,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	A                    *int32                  `protobuf:"varint,17,opt,name=a" json:"a,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestAllTypes_OptionalGroup) Reset() {
@@ -1618,10 +1618,10 @@
 }
 
 type TestAllTypes_RepeatedGroup struct {
-	A                    *int32   `protobuf:"varint,47,opt,name=a" json:"a,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	A                    *int32                  `protobuf:"varint,47,opt,name=a" json:"a,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestAllTypes_RepeatedGroup) Reset() {
@@ -1655,10 +1655,10 @@
 }
 
 type TestRequiredGroupFields_OptionalGroup struct {
-	A                    *int32   `protobuf:"varint,2,req,name=a" json:"a,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	A                    *int32                  `protobuf:"varint,2,req,name=a" json:"a,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestRequiredGroupFields_OptionalGroup) Reset() {
@@ -1692,10 +1692,10 @@
 }
 
 type TestRequiredGroupFields_RepeatedGroup struct {
-	A                    *int32   `protobuf:"varint,4,req,name=a" json:"a,omitempty"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	A                    *int32                  `protobuf:"varint,4,req,name=a" json:"a,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestRequiredGroupFields_RepeatedGroup) Reset() {
diff --git a/internal/testprotos/test/test_import.pb.go b/internal/testprotos/test/test_import.pb.go
index eb889ee..3b9766f 100644
--- a/internal/testprotos/test/test_import.pb.go
+++ b/internal/testprotos/test/test_import.pb.go
@@ -63,9 +63,9 @@
 }
 
 type ImportMessage struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *ImportMessage) Reset() {
diff --git a/internal/testprotos/test/test_public.pb.go b/internal/testprotos/test/test_public.pb.go
index 7132a4b..4f12706 100644
--- a/internal/testprotos/test/test_public.pb.go
+++ b/internal/testprotos/test/test_public.pb.go
@@ -14,9 +14,9 @@
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
 type PublicImportMessage struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *PublicImportMessage) Reset() {
diff --git a/internal/testprotos/test/test_weak.pb.go b/internal/testprotos/test/test_weak.pb.go
index b36082b..0a716ef 100644
--- a/internal/testprotos/test/test_weak.pb.go
+++ b/internal/testprotos/test/test_weak.pb.go
@@ -14,9 +14,9 @@
 const _ = protoimpl.EnforceVersion(protoimpl.Version - 0)
 
 type WeakImportMessage struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *WeakImportMessage) Reset() {
diff --git a/internal/testprotos/test3/test.pb.go b/internal/testprotos/test3/test.pb.go
index d2d2a61..d871a2e 100644
--- a/internal/testprotos/test3/test.pb.go
+++ b/internal/testprotos/test3/test.pb.go
@@ -169,8 +169,8 @@
 	//	*TestAllTypes_OneofEnum
 	OneofField           isTestAllTypes_OneofField `protobuf_oneof:"oneof_field"`
 	XXX_NoUnkeyedLiteral struct{}                  `json:"-"`
-	XXX_unrecognized     []byte                    `json:"-"`
-	XXX_sizecache        int32                     `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields   `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache       `json:"-"`
 }
 
 func (x *TestAllTypes) Reset() {
@@ -753,11 +753,11 @@
 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"`
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	C                    int32                   `protobuf:"varint,1,opt,name=c,proto3" json:"c,omitempty"`
+	D                    int32                   `protobuf:"varint,2,opt,name=d,proto3" json:"d,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *ForeignMessage) Reset() {
@@ -798,11 +798,11 @@
 }
 
 type TestAllTypes_NestedMessage struct {
-	A                    int32         `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
-	Corecursive          *TestAllTypes `protobuf:"bytes,2,opt,name=corecursive,proto3" json:"corecursive,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}      `json:"-"`
-	XXX_unrecognized     []byte        `json:"-"`
-	XXX_sizecache        int32         `json:"-"`
+	A                    int32                   `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"`
+	Corecursive          *TestAllTypes           `protobuf:"bytes,2,opt,name=corecursive,proto3" json:"corecursive,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *TestAllTypes_NestedMessage) Reset() {
diff --git a/internal/testprotos/test3/test_import.pb.go b/internal/testprotos/test3/test_import.pb.go
index 2ee6535..385827b 100644
--- a/internal/testprotos/test3/test_import.pb.go
+++ b/internal/testprotos/test3/test_import.pb.go
@@ -47,9 +47,9 @@
 }
 
 type ImportMessage struct {
-	XXX_NoUnkeyedLiteral struct{} `json:"-"`
-	XXX_unrecognized     []byte   `json:"-"`
-	XXX_sizecache        int32    `json:"-"`
+	XXX_NoUnkeyedLiteral struct{}                `json:"-"`
+	XXX_unrecognized     protoimpl.UnknownFields `json:"-"`
+	XXX_sizecache        protoimpl.SizeCache     `json:"-"`
 }
 
 func (x *ImportMessage) Reset() {