square / wire

gRPC and protocol buffers for Android, Kotlin, Swift and Java.
https://square.github.io/wire/
Apache License 2.0
4.25k stars 570 forks source link

Enums: Null can not be a value of a non-null type String #1785

Closed kronstein closed 4 years ago

kronstein commented 4 years ago

Extending enums doesn't compile if at least one enum value doesn't provide all options values. I believe it should compile, as in google's implementation.

Example:

import "google/protobuf/descriptor.proto";
import "google/protobuf/wrappers.proto";

extend google.protobuf.EnumValueOptions
{
  string english = 55556;
  bool lost = 55557;
}

package mia.kronstein.codevein;

// https://codevein.wiki.fextralife.com/Blood+Code
message BloodCode {
  enum CodeOwner {
    Unknown = 0;
    OliverCollins = 1 [(english)="Oliver Collins", (lost)=true];
    Louis = 2  [(english)="Louis", (lost)=false];
  }

  string name = 1;
  CodeOwner owner = 2;
}

Output:

e: D:\StudioProjects\WireTest\app\build\generated\source\wire\mia\kronstein\codevein\BloodCode.kt: (145, 16): Null can not be a value of a non-null type String
e: D:\StudioProjects\WireTest\app\build\generated\source\wire\mia\kronstein\codevein\BloodCode.kt: (145, 22): Null can not be a value of a non-null type Boolean
oldergod commented 4 years ago

Fix has been released today in 3.4.0.