question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile error when proto contains a oneof field with same name as the enclosing message

See original GitHub issue

From 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
garypcommented, Dec 28, 2020

Fixed in #104 for the upcoming 0.9.1 release. I’ve also cherry-picked the fix into the master branch in #115.

1reaction
nbazteccommented, Nov 19, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found