reflect/protoreflect: drop the ProtoEnum type
Drop the protoreflect.ProtoEnum type (containing a single method
returning a protoreflect.Enum) and make generated enum types
directly implement protoreflect.Enum instead.
Messages have a two-level type split (ProtoMessage and Message) to
minimize conflicts between reflection methods and field names. Enums
need no such split, since enums do not have fields and therefore have
no source of conflicts.
Change-Id: I2b6222e9404253e6bfef2217859e1b760ffcd29b
Reviewed-on: https://go-review.googlesource.com/c/156902
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/cmd/protoc-gen-go/internal_gengo/reflect.go b/cmd/protoc-gen-go/internal_gengo/reflect.go
index 4cc1089..69de0df 100644
--- a/cmd/protoc-gen-go/internal_gengo/reflect.go
+++ b/cmd/protoc-gen-go/internal_gengo/reflect.go
@@ -191,7 +191,7 @@
for i, enum := range f.allEnums {
g.P(prototypePackage.Ident("GoEnum"), "(")
g.P(enumDescsVar, "[", i, "].Reference(),")
- g.P("func(_ ", protoreflectPackage.Ident("EnumType"), ", n ", protoreflectPackage.Ident("EnumNumber"), ") ", protoreflectPackage.Ident("ProtoEnum"), " {")
+ g.P("func(_ ", protoreflectPackage.Ident("EnumType"), ", n ", protoreflectPackage.Ident("EnumNumber"), ") ", protoreflectPackage.Ident("Enum"), " {")
g.P("return ", enum.GoIdent, "(n)")
g.P("},")
g.P("),")
@@ -352,19 +352,12 @@
return
}
- shadowType := shadowTypeName(enum.GoIdent)
- g.P("type ", shadowType, " ", enum.GoIdent)
- g.P()
-
idx := f.allEnumsByPtr[enum]
typesVar := enumTypesVarName(f)
- g.P("func (e ", enum.GoIdent, ") ProtoReflect() ", protoreflectPackage.Ident("Enum"), " {")
- g.P("return (", shadowType, ")(e)")
- g.P("}")
- g.P("func (e ", shadowType, ") Type() ", protoreflectPackage.Ident("EnumType"), " {")
+ g.P("func (e ", enum.GoIdent, ") Type() ", protoreflectPackage.Ident("EnumType"), " {")
g.P("return ", typesVar, "[", idx, "]")
g.P("}")
- g.P("func (e ", shadowType, ") Number() ", protoreflectPackage.Ident("EnumNumber"), " {")
+ g.P("func (e ", enum.GoIdent, ") Number() ", protoreflectPackage.Ident("EnumNumber"), " {")
g.P("return ", protoreflectPackage.Ident("EnumNumber"), "(e)")
g.P("}")
}
diff --git a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
index ef72ffd..ddba63c 100644
--- a/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
+++ b/cmd/protoc-gen-go/testdata/annotations/annotations.pb.go
@@ -22,15 +22,10 @@
AnnotationsTestEnum_ANNOTATIONS_TEST_ENUM_VALUE AnnotationsTestEnum = 0
)
-type xxx_AnnotationsTestEnum AnnotationsTestEnum
-
-func (e AnnotationsTestEnum) ProtoReflect() protoreflect.Enum {
- return (xxx_AnnotationsTestEnum)(e)
-}
-func (e xxx_AnnotationsTestEnum) Type() protoreflect.EnumType {
+func (e AnnotationsTestEnum) Type() protoreflect.EnumType {
return xxx_Annotations_ProtoFile_EnumTypes[0]
}
-func (e xxx_AnnotationsTestEnum) Number() protoreflect.EnumNumber {
+func (e AnnotationsTestEnum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -167,7 +162,7 @@
var xxx_Annotations_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Annotations_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return AnnotationsTestEnum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
index ae3d74b..b981bae 100644
--- a/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
+++ b/cmd/protoc-gen-go/testdata/comments/deprecated.pb.go
@@ -21,15 +21,10 @@
DeprecatedEnum_DEPRECATED DeprecatedEnum = 0 // Deprecated: Do not use.
)
-type xxx_DeprecatedEnum DeprecatedEnum
-
-func (e DeprecatedEnum) ProtoReflect() protoreflect.Enum {
- return (xxx_DeprecatedEnum)(e)
-}
-func (e xxx_DeprecatedEnum) Type() protoreflect.EnumType {
+func (e DeprecatedEnum) Type() protoreflect.EnumType {
return xxx_Deprecated_ProtoFile_EnumTypes[0]
}
-func (e xxx_DeprecatedEnum) Number() protoreflect.EnumNumber {
+func (e DeprecatedEnum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -153,7 +148,7 @@
var xxx_Deprecated_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Deprecated_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return DeprecatedEnum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
index 2a948e1..fc1c914 100644
--- a/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/ext/ext.pb.go
@@ -24,15 +24,10 @@
Enum_ZERO Enum = 0
)
-type xxx_Enum Enum
-
-func (e Enum) ProtoReflect() protoreflect.Enum {
- return (xxx_Enum)(e)
-}
-func (e xxx_Enum) Type() protoreflect.EnumType {
+func (e Enum) Type() protoreflect.EnumType {
return xxx_Ext_ProtoFile_EnumTypes[0]
}
-func (e xxx_Enum) Number() protoreflect.EnumNumber {
+func (e Enum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -1058,7 +1053,7 @@
var xxx_Ext_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Ext_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return Enum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
index aa8b177..550921b 100644
--- a/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
+++ b/cmd/protoc-gen-go/testdata/extensions/proto3/ext3.pb.go
@@ -23,15 +23,10 @@
Enum_ZERO Enum = 0
)
-type xxx_Enum Enum
-
-func (e Enum) ProtoReflect() protoreflect.Enum {
- return (xxx_Enum)(e)
-}
-func (e xxx_Enum) Type() protoreflect.EnumType {
+func (e Enum) Type() protoreflect.EnumType {
return xxx_Ext3_ProtoFile_EnumTypes[0]
}
-func (e xxx_Enum) Number() protoreflect.EnumNumber {
+func (e Enum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -523,7 +518,7 @@
var xxx_Ext3_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Ext3_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return Enum(n)
},
),
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 3e83c85..87b3229 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
@@ -28,15 +28,10 @@
E_ZERO E = 0
)
-type xxx_E E
-
-func (e E) ProtoReflect() protoreflect.Enum {
- return (xxx_E)(e)
-}
-func (e xxx_E) Type() protoreflect.EnumType {
+func (e E) Type() protoreflect.EnumType {
return xxx_A_ProtoFile_EnumTypes[0]
}
-func (e xxx_E) Number() protoreflect.EnumNumber {
+func (e E) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -77,15 +72,10 @@
M_M_ZERO M_Subenum = 0
)
-type xxx_M_Subenum M_Subenum
-
-func (e M_Subenum) ProtoReflect() protoreflect.Enum {
- return (xxx_M_Subenum)(e)
-}
-func (e xxx_M_Subenum) Type() protoreflect.EnumType {
+func (e M_Subenum) Type() protoreflect.EnumType {
return xxx_A_ProtoFile_EnumTypes[1]
}
-func (e xxx_M_Subenum) Number() protoreflect.EnumNumber {
+func (e M_Subenum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -126,15 +116,10 @@
M_Submessage_M_SUBMESSAGE_ZERO M_Submessage_Submessage_Subenum = 0
)
-type xxx_M_Submessage_Submessage_Subenum M_Submessage_Submessage_Subenum
-
-func (e M_Submessage_Submessage_Subenum) ProtoReflect() protoreflect.Enum {
- return (xxx_M_Submessage_Submessage_Subenum)(e)
-}
-func (e xxx_M_Submessage_Submessage_Subenum) Type() protoreflect.EnumType {
+func (e M_Submessage_Submessage_Subenum) Type() protoreflect.EnumType {
return xxx_A_ProtoFile_EnumTypes[2]
}
-func (e xxx_M_Submessage_Submessage_Subenum) Number() protoreflect.EnumNumber {
+func (e M_Submessage_Submessage_Subenum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -491,19 +476,19 @@
var xxx_A_ProtoFile_EnumTypes = [3]protoreflect.EnumType{
prototype.GoEnum(
xxx_A_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return E(n)
},
),
prototype.GoEnum(
xxx_A_ProtoFile_EnumDescs[1].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return M_Subenum(n)
},
),
prototype.GoEnum(
xxx_A_ProtoFile_EnumDescs[2].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return M_Submessage_Submessage_Subenum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
index 91da206..1cc319c 100644
--- a/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
+++ b/cmd/protoc-gen-go/testdata/imports/test_a_1/m1.pb.go
@@ -22,15 +22,10 @@
E1_E1_ZERO E1 = 0
)
-type xxx_E1 E1
-
-func (e E1) ProtoReflect() protoreflect.Enum {
- return (xxx_E1)(e)
-}
-func (e xxx_E1) Type() protoreflect.EnumType {
+func (e E1) Type() protoreflect.EnumType {
return xxx_M1_ProtoFile_EnumTypes[0]
}
-func (e xxx_E1) Number() protoreflect.EnumNumber {
+func (e E1) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -201,7 +196,7 @@
var xxx_M1_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_M1_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return E1(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
index 6bfdcee..b1f2540 100644
--- a/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
+++ b/cmd/protoc-gen-go/testdata/nopackage/nopackage.pb.go
@@ -22,15 +22,10 @@
Enum_ZERO Enum = 0
)
-type xxx_Enum Enum
-
-func (e Enum) ProtoReflect() protoreflect.Enum {
- return (xxx_Enum)(e)
-}
-func (e xxx_Enum) Type() protoreflect.EnumType {
+func (e Enum) Type() protoreflect.EnumType {
return xxx_Nopackage_ProtoFile_EnumTypes[0]
}
-func (e xxx_Enum) Number() protoreflect.EnumNumber {
+func (e Enum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -174,7 +169,7 @@
var xxx_Nopackage_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Nopackage_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return Enum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
index f5d0dd4..7e70607 100644
--- a/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/enum.pb.go
@@ -26,15 +26,10 @@
EnumType1_TWO EnumType1 = 2
)
-type xxx_EnumType1 EnumType1
-
-func (e EnumType1) ProtoReflect() protoreflect.Enum {
- return (xxx_EnumType1)(e)
-}
-func (e xxx_EnumType1) Type() protoreflect.EnumType {
+func (e EnumType1) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[0]
}
-func (e xxx_EnumType1) Number() protoreflect.EnumNumber {
+func (e EnumType1) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -78,15 +73,10 @@
EnumType2_duplicate2 EnumType2 = 1
)
-type xxx_EnumType2 EnumType2
-
-func (e EnumType2) ProtoReflect() protoreflect.Enum {
- return (xxx_EnumType2)(e)
-}
-func (e xxx_EnumType2) Type() protoreflect.EnumType {
+func (e EnumType2) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[1]
}
-func (e xxx_EnumType2) Number() protoreflect.EnumNumber {
+func (e EnumType2) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -131,15 +121,10 @@
EnumContainerMessage1_NESTED_1A_VALUE EnumContainerMessage1_NestedEnumType1A = 0
)
-type xxx_EnumContainerMessage1_NestedEnumType1A EnumContainerMessage1_NestedEnumType1A
-
-func (e EnumContainerMessage1_NestedEnumType1A) ProtoReflect() protoreflect.Enum {
- return (xxx_EnumContainerMessage1_NestedEnumType1A)(e)
-}
-func (e xxx_EnumContainerMessage1_NestedEnumType1A) Type() protoreflect.EnumType {
+func (e EnumContainerMessage1_NestedEnumType1A) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[2]
}
-func (e xxx_EnumContainerMessage1_NestedEnumType1A) Number() protoreflect.EnumNumber {
+func (e EnumContainerMessage1_NestedEnumType1A) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -180,15 +165,10 @@
EnumContainerMessage1_NESTED_1B_VALUE EnumContainerMessage1_NestedEnumType1B = 0
)
-type xxx_EnumContainerMessage1_NestedEnumType1B EnumContainerMessage1_NestedEnumType1B
-
-func (e EnumContainerMessage1_NestedEnumType1B) ProtoReflect() protoreflect.Enum {
- return (xxx_EnumContainerMessage1_NestedEnumType1B)(e)
-}
-func (e xxx_EnumContainerMessage1_NestedEnumType1B) Type() protoreflect.EnumType {
+func (e EnumContainerMessage1_NestedEnumType1B) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[3]
}
-func (e xxx_EnumContainerMessage1_NestedEnumType1B) Number() protoreflect.EnumNumber {
+func (e EnumContainerMessage1_NestedEnumType1B) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -231,15 +211,10 @@
EnumContainerMessage1_EnumContainerMessage2_NESTED_2A_VALUE EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A = 0
)
-type xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A
-
-func (e EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) ProtoReflect() protoreflect.Enum {
- return (xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A)(e)
-}
-func (e xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Type() protoreflect.EnumType {
+func (e EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[4]
}
-func (e xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Number() protoreflect.EnumNumber {
+func (e EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -280,15 +255,10 @@
EnumContainerMessage1_EnumContainerMessage2_NESTED_2B_VALUE EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B = 0
)
-type xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B
-
-func (e EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) ProtoReflect() protoreflect.Enum {
- return (xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B)(e)
-}
-func (e xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Type() protoreflect.EnumType {
+func (e EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[5]
}
-func (e xxx_EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Number() protoreflect.EnumNumber {
+func (e EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -509,37 +479,37 @@
var xxx_Enum_ProtoFile_EnumTypes = [6]protoreflect.EnumType{
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return EnumType1(n)
},
),
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[1].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return EnumType2(n)
},
),
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[2].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return EnumContainerMessage1_NestedEnumType1A(n)
},
),
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[3].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return EnumContainerMessage1_NestedEnumType1B(n)
},
),
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[4].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2A(n)
},
),
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[5].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return EnumContainerMessage1_EnumContainerMessage2_NestedEnumType2B(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
index 0e51367..3adf069 100644
--- a/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto2/fields.pb.go
@@ -24,15 +24,10 @@
FieldTestMessage_ONE FieldTestMessage_Enum = 1
)
-type xxx_FieldTestMessage_Enum FieldTestMessage_Enum
-
-func (e FieldTestMessage_Enum) ProtoReflect() protoreflect.Enum {
- return (xxx_FieldTestMessage_Enum)(e)
-}
-func (e xxx_FieldTestMessage_Enum) Type() protoreflect.EnumType {
+func (e FieldTestMessage_Enum) Type() protoreflect.EnumType {
return xxx_Fields_ProtoFile_EnumTypes[0]
}
-func (e xxx_FieldTestMessage_Enum) Number() protoreflect.EnumNumber {
+func (e FieldTestMessage_Enum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -1608,7 +1603,7 @@
var xxx_Fields_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Fields_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return FieldTestMessage_Enum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
index 328a439..dcb4a9e 100644
--- a/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/enum.pb.go
@@ -24,15 +24,10 @@
Enum_TWO Enum = 2
)
-type xxx_Enum Enum
-
-func (e Enum) ProtoReflect() protoreflect.Enum {
- return (xxx_Enum)(e)
-}
-func (e xxx_Enum) Type() protoreflect.EnumType {
+func (e Enum) Type() protoreflect.EnumType {
return xxx_Enum_ProtoFile_EnumTypes[0]
}
-func (e xxx_Enum) Number() protoreflect.EnumNumber {
+func (e Enum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -95,7 +90,7 @@
var xxx_Enum_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Enum_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return Enum(n)
},
),
diff --git a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
index 1701832..6d47099 100644
--- a/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
+++ b/cmd/protoc-gen-go/testdata/proto3/fields.pb.go
@@ -22,15 +22,10 @@
FieldTestMessage_ZERO FieldTestMessage_Enum = 0
)
-type xxx_FieldTestMessage_Enum FieldTestMessage_Enum
-
-func (e FieldTestMessage_Enum) ProtoReflect() protoreflect.Enum {
- return (xxx_FieldTestMessage_Enum)(e)
-}
-func (e xxx_FieldTestMessage_Enum) Type() protoreflect.EnumType {
+func (e FieldTestMessage_Enum) Type() protoreflect.EnumType {
return xxx_Fields_ProtoFile_EnumTypes[0]
}
-func (e xxx_FieldTestMessage_Enum) Number() protoreflect.EnumNumber {
+func (e FieldTestMessage_Enum) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(e)
}
@@ -542,7 +537,7 @@
var xxx_Fields_ProtoFile_EnumTypes = [1]protoreflect.EnumType{
prototype.GoEnum(
xxx_Fields_ProtoFile_EnumDescs[0].Reference(),
- func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.ProtoEnum {
+ func(_ protoreflect.EnumType, n protoreflect.EnumNumber) protoreflect.Enum {
return FieldTestMessage_Enum(n)
},
),