THRIFT-3795 Generated hashValue method in Swift will overflow
Client: Swift
Patch: HÃ¥kon Hitland
diff --git a/compiler/cpp/src/generate/t_swift_generator.cc b/compiler/cpp/src/generate/t_swift_generator.cc
index 4b33993..a577c3d 100644
--- a/compiler/cpp/src/generate/t_swift_generator.cc
+++ b/compiler/cpp/src/generate/t_swift_generator.cc
@@ -562,7 +562,7 @@
t_field* tfield = *m_iter;
string accessor = field_is_optional(tfield) ? "?." : ".";
string defaultor = field_is_optional(tfield) ? " ?? 0" : "";
- indent(out) << "result = prime * result + (" << tfield->get_name() << accessor << "hashValue" << defaultor << ")" << endl;
+ indent(out) << "result = prime &* result &+ (" << tfield->get_name() << accessor << "hashValue" << defaultor << ")" << endl;
}
indent(out) << "return result" << endl;