all: add EDITION_UNSTABLE support The UNSTABLE edition serves as a sandbox for all features in-development. The --experimental_edition protoc flag is required to accept it. Google-Internally, see go/edition-unstable for more details. Originally authored by Rachel Goldfinger, who asked me to send the change. Change-Id: If3acc284f70b7690e837d4746202823880a13355 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/727960 Reviewed-by: Lasse Folger <lassefolger@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/internal/filedesc/desc.go b/internal/filedesc/desc.go index dbcf90b..c775e58 100644 --- a/internal/filedesc/desc.go +++ b/internal/filedesc/desc.go
@@ -32,6 +32,7 @@ EditionProto3 Edition = 999 Edition2023 Edition = 1000 Edition2024 Edition = 1001 + EditionUnstable Edition = 9999 EditionUnsupported Edition = 100000 )
diff --git a/reflect/protodesc/desc.go b/reflect/protodesc/desc.go index f69c78a..40f17af 100644 --- a/reflect/protodesc/desc.go +++ b/reflect/protodesc/desc.go
@@ -108,7 +108,9 @@ if f.L1.Path == "" { return nil, errors.New("file path must be populated") } - if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) { + if f.L1.Syntax == protoreflect.Editions && + (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) && + fd.GetEdition() != descriptorpb.Edition_EDITION_UNSTABLE { // Allow cmd/protoc-gen-go/testdata to use any edition for easier // testing of upcoming edition features. if !strings.HasPrefix(fd.GetName(), "cmd/protoc-gen-go/testdata/") {
diff --git a/reflect/protodesc/editions.go b/reflect/protodesc/editions.go index 697a61b..b4dd61c 100644 --- a/reflect/protodesc/editions.go +++ b/reflect/protodesc/editions.go
@@ -58,7 +58,7 @@ return def } edpb := toEditionProto(ed) - if defaults.GetMinimumEdition() > edpb || defaults.GetMaximumEdition() < edpb { + if (defaults.GetMinimumEdition() > edpb || defaults.GetMaximumEdition() < edpb) && edpb != descriptorpb.Edition_EDITION_UNSTABLE { // This should never happen protodesc.(FileOptions).New would fail when // initializing the file descriptor. // This most likely means the embedded defaults were not updated.