diff --git a/proto/compiler/google/src/google/protobuf/compiler/kotlin/error_codes b/proto/compiler/google/src/google/protobuf/compiler/kotlin/error_codes index b9e207e6a65..aef2cc98324 100644 --- a/proto/compiler/google/src/google/protobuf/compiler/kotlin/error_codes +++ b/proto/compiler/google/src/google/protobuf/compiler/kotlin/error_codes @@ -1,3 +1,4 @@ 1 - mismatch of expected and actual WireType in parseFieldFrom method 2 - read message of size that exceeds expected in parseFromWithSize method 3 - read message of size that is not equal to expected. Can occur when deserializing nested message (code generated in C++ method generateSerializationMethods) +4 - unsupported feature: unknown field encountered \ No newline at end of file diff --git a/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_class_generator.cc b/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_class_generator.cc index 1c7c4f3c96f..939e6c0af69 100644 --- a/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_class_generator.cc +++ b/proto/compiler/google/src/google/protobuf/compiler/kotlin/src/kotlin_class_generator.cc @@ -170,6 +170,7 @@ void ClassGenerator::generateMergeMethods(io::Printer *printer) const { } } + printer->Print("this.errorCode = other.errorCode\n"); printer->Outdent(); printer->Print("}\n"); @@ -246,14 +247,18 @@ void ClassGenerator::generateBuildMethod(io::Printer * printer) const { // pass all fields to constructor of enclosing class printer->Print(vars, - "return $returnType$("); + "val res = $returnType$("); for (int i = 0; i < properties.size(); ++i) { printer->Print(properties[i]->simpleName.c_str()); if (i + 1 != properties.size()) { printer->Print(", "); } } + printer->Print(")\n"); + printer->Print("res.errorCode = errorCode\n"); + printer->Print("return res\n"); + printer->Outdent(); printer->Print("}\n"); } @@ -318,7 +323,7 @@ void ClassGenerator::generateParseMethods(io::Printer *printer) const { printer->Print("}\n"); } - // TODO: add parsing of unknown fields + printer->Print(vars, "else -> errorCode = 4\n"); printer->Outdent(); printer->Print("}\n"); // when-clause