Scoped enums would actually require no other behavior change in many of the languages like Java, as the gencode actually uses a language enum which is already scoped anyway. So in Java you're just going to get `Foo.BAR` like you want without us having to do much special there.
The C++ case is actually fairly odd today, basically what happens with the wrapping type is that there's first an enum which manually prefixes everything with the nested scope basically like this (the C++ enum semantic is that all of the constants inside are not scoped by the containing enum)
enum Wrapper_Foo : int {
Wrapper_Foo_UNSPECIFIED = 0;
Wrapper_Foo_BAR = 1;
}
And then later the actual message class has `using` statements that expose the type and names under that scape, like:
class Wrapper {
using Foo = Wrapper_Foo;
static constexpr Foo UNSPECIFIED = Wrapper_Foo_UNSPECIFIED;
static constexpr Foo BAR = Wrapper_Foo_BAR;
}
So today it is possible to write the enum type as either `Wrapper_Foo` or `Wrapper::Foo`, and possible to name the values as either `Wrapper::BAR` or `Wrapper_Foo_Bar`. You can see that this still would have the name collisions if you had 2 enums nested in the same message and the value names collided, since the values are also 'directly' underneath `Wrapper` without any `Foo` in them there.
C++ the language added scoped enums all the way back in C++11 (they look like `enum class Foo {}`) so its far overdue for us to be able to have the gencode use it there, then we can start to emit it as:
enum class Foo : int {
UNSPECIFIED = 0;
BAR = 1;
}
And you can finally write Foo::UNSPECIFIED like you naturally want to.
All that to say, with scoped enums you will want to put them at top level instead of synthetically-nested in a message and the 'spelling' won't match. It's also a possibility that we could have some sort of shim migration mode to facilitate people trying to incrementally move off the nested-message-to-scope-pattern onto proper-scoped-enums but I'm not exactly sure what it could look like to be a super smooth migration.