diff options
author | Jens Geyer <jensg@apache.org> | 2013-07-26 00:23:00 +0200 |
---|---|---|
committer | Jens Geyer <jensg@apache.org> | 2013-07-26 00:23:00 +0200 |
commit | 11430df7ae96d184a5778f5f6eb3c93e65389eba (patch) | |
tree | c5c390d086f6bdcb516f65eb78211c4126488e1d | |
parent | 56a648d0ffc370123c4f1047b72d0d80080a1d9b (diff) | |
download | thrift-11430df7ae96d184a5778f5f6eb3c93e65389eba.tar.gz |
THRIFT-2102 constants are not referencing to correct type when included from another thrift file
Patch: Remo Hertig
-rw-r--r-- | compiler/cpp/src/generate/t_go_generator.cc | 3 | ||||
-rw-r--r-- | lib/go/test/IncludesTest.thrift | 3 | ||||
-rw-r--r-- | test/ThriftTest.thrift | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc index 0f4951b0c..4a3888542 100644 --- a/compiler/cpp/src/generate/t_go_generator.cc +++ b/compiler/cpp/src/generate/t_go_generator.cc @@ -509,6 +509,7 @@ void t_go_generator::init_generator() f_consts_ << go_package() << + render_includes() << go_autogen_comment(); f_const_values_ << endl << "func init() {" << endl; @@ -767,7 +768,7 @@ string t_go_generator::render_const_value(t_type* type, t_const_value* value, co indent(out) << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { out << - "&" << publicize(type->get_name()) << "{"; + "&" << publicize(type_name(type)) << "{"; indent_up(); const vector<t_field*>& fields = ((t_struct*)type)->get_members(); vector<t_field*>::const_iterator f_iter; diff --git a/lib/go/test/IncludesTest.thrift b/lib/go/test/IncludesTest.thrift index 4416c0992..6b6880622 100644 --- a/lib/go/test/IncludesTest.thrift +++ b/lib/go/test/IncludesTest.thrift @@ -19,6 +19,9 @@ include "ThriftTest.thrift" +const ThriftTest.UserId USERID = 42 +const ThriftTest.MapType MAPCONSTANT = {'hello':{}, 'goodnight':{}} + struct testStruct { 1: list<ThriftTest.Numberz> listNumbers } diff --git a/test/ThriftTest.thrift b/test/ThriftTest.thrift index be000b6a9..500f0eab3 100644 --- a/test/ThriftTest.thrift +++ b/test/ThriftTest.thrift @@ -68,6 +68,8 @@ struct Bonk 2: i32 type } +typedef map<string,Bonk> MapType + struct Bools { 1: bool im_true, 2: bool im_false, |