From 431732d39e89f1661dc7dddffedb2c5c1e019cc7 Mon Sep 17 00:00:00 2001 From: "D. Can Celasun" Date: Fri, 3 Mar 2017 12:03:24 +0100 Subject: [PATCH] THRIFT-4031: Fix invalid code generation for list of typedef'ed built-in types Client: Go Patch: D. Can Celasun This closes #1207 This commit reverts 12d430e723b020f7a8ce42a40c19edf88f948367 which caused invalid code to be generated for certain types. --- .../cpp/src/thrift/generate/t_go_generator.cc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc index 14b359745..088f3aeb1 100644 --- a/compiler/cpp/src/thrift/generate/t_go_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc @@ -178,8 +178,7 @@ public: bool inclass = false, bool coerceData = false, bool inkey = false, - bool in_container = false, - bool use_true_type = false); + bool in_container = false); void generate_deserialize_struct(std::ofstream& out, t_struct* tstruct, @@ -2830,8 +2829,7 @@ void t_go_generator::generate_deserialize_field(ofstream& out, bool inclass, bool coerceData, bool inkey, - bool in_container_value, - bool use_true_type) { + bool in_container_value) { (void)inclass; (void)coerceData; t_type* orig_type = tfield->get_type(); @@ -2853,10 +2851,8 @@ void t_go_generator::generate_deserialize_field(ofstream& out, } else if (type->is_base_type() || type->is_enum()) { if (declare) { - t_type* actual_type = use_true_type ? tfield->get_type()->get_true_type() - : tfield->get_type(); - - string type_name = inkey ? type_to_go_key_type(actual_type) : type_to_go_type(actual_type); + string type_name = inkey ? type_to_go_key_type(tfield->get_type()) + : type_to_go_type(tfield->get_type()); out << "var " << tfield->get_name() << " " << type_name << endl; } @@ -2918,7 +2914,7 @@ void t_go_generator::generate_deserialize_field(ofstream& out, out << "} else {" << endl; string wrap; - if (type->is_enum() || (orig_type->is_typedef() && !use_true_type)) { + if (type->is_enum() || orig_type->is_typedef()) { wrap = publicize(type_name(orig_type)); } else if (((t_base_type*)type)->get_base() == t_base_type::TYPE_I8) { wrap = "int8"; @@ -3064,7 +3060,7 @@ void t_go_generator::generate_deserialize_set_element(ofstream& out, string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); felem.set_req(t_field::T_OPT_IN_REQ_OUT); - generate_deserialize_field(out, &felem, true, "", false, false, false, true, true); + generate_deserialize_field(out, &felem, true, "", false, false, false, true); indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl; } @@ -3079,7 +3075,7 @@ void t_go_generator::generate_deserialize_list_element(ofstream& out, string elem = tmp("_elem"); t_field felem(((t_list*)tlist)->get_elem_type(), elem); felem.set_req(t_field::T_OPT_IN_REQ_OUT); - generate_deserialize_field(out, &felem, true, "", false, false, false, true, true); + generate_deserialize_field(out, &felem, true, "", false, false, false, true); indent(out) << prefix << " = append(" << prefix << ", " << elem << ")" << endl; }