Compile error when proto contains a oneof field with same name as the enclosing message
See original GitHub issueFrom https://github.com/streem/pbandk/issues/18#issuecomment-632369786:
A proto definition such as:
message Value {
oneof value {
string string_value = 1;
bool boolean_value = 2;
int32 integer_value = 3;
int64 long_value = 4;
float float_value = 5;
double double_value = 6;
int64 date_value = 7;
}
}
Generates code like:
data class Value(
val value: Value<*>? = null
) {
sealed class Value<V>(value: V) : pbandk.Message.OneOf<V>(value) {
class StringValue(stringValue: String = "") : Value<String>(stringValue)
...
}
...
}
Which fails to compile because there are two types named Value
and the type of value
in val value: Value<*>? = null
can’t be resolved correctly.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Language Guide | Protocol Buffers - Google Developers
The SearchRequest message definition specifies three fields (name/value pairs), one for each piece of data that you want to include in this type...
Read more >proto - The Go Programming Language - GitHub Pages
Enum values are prefixed by the enclosing message's name, or by the enum's type name if it is a top-level enum. Enum types...
Read more >How to represent a mix of enum and oneof in protobuf
Essentially, I would like a field that can represent either an error type that is just a name with no fields, or an...
Read more >google.protobuf.descriptor — Protocol Buffers 4.21.1 ...
Fully-qualified name of this protocol message type, which will include protocol ... Same FieldDescriptor objects as in fields , but indexed by “name” ......
Read more >Change Log - CocoaPods
Breaking: SchemaLoader and related classes have been moved from wire-compiler to wire-schema . New: Support packed and map fields when converting to/from ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fixed in #104 for the upcoming 0.9.1 release. I’ve also cherry-picked the fix into the master branch in #115.
Hi, went overt he code real quick but could you perhaps point out to a test that could be used to validate the fix?
CodeGenerator
takes in a file context, but I couldn’t find any single point to test with a sample proto file.