You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2013/08/03 10:24:19 UTC
git commit: THRIFT-2112 Error in Go generator when using typedefs in
map keys
Updated Branches:
refs/heads/master aa721610d -> 656a17305
THRIFT-2112 Error in Go generator when using typedefs in map keys
Patch: Emir Habul
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/656a1730
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/656a1730
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/656a1730
Branch: refs/heads/master
Commit: 656a17305093a1fda754b669f4cb9ce4e98ec2d1
Parents: aa72161
Author: Jens Geyer <je...@apache.org>
Authored: Sat Aug 3 10:22:39 2013 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Sat Aug 3 10:22:39 2013 +0200
----------------------------------------------------------------------
compiler/cpp/src/generate/t_go_generator.cc | 9 ++++-----
lib/go/test/IncludesTest.thrift | 10 ++++++++++
2 files changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/656a1730/compiler/cpp/src/generate/t_go_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc
index 43c4766..288bfab 100644
--- a/compiler/cpp/src/generate/t_go_generator.cc
+++ b/compiler/cpp/src/generate/t_go_generator.cc
@@ -3175,15 +3175,14 @@ string t_go_generator::type_to_enum(t_type* type)
*/
string t_go_generator::type_to_go_key_type(t_type* type)
{
- string go_type = type_to_go_type(type);
+ t_type* resolved_type = type;
- while (type->is_typedef()) {
- type = ((t_typedef*)type)->get_type();
+ while (resolved_type->is_typedef()) {
+ resolved_type = ((t_typedef*)resolved_type)->get_type();
}
- if (type->is_map() || type->is_list() || type->is_set()) {
+ if (resolved_type->is_map() || resolved_type->is_list() || resolved_type->is_set()) {
throw "Cannot produce a valid type for a Go map key: " + type_to_go_type(type) + " - aborting.";
-
}
return type_to_go_type(type);
http://git-wip-us.apache.org/repos/asf/thrift/blob/656a1730/lib/go/test/IncludesTest.thrift
----------------------------------------------------------------------
diff --git a/lib/go/test/IncludesTest.thrift b/lib/go/test/IncludesTest.thrift
index 6f80e6b..3f60321 100644
--- a/lib/go/test/IncludesTest.thrift
+++ b/lib/go/test/IncludesTest.thrift
@@ -55,3 +55,13 @@ service Extended2Service extends NamespacedTest.NamespacedService {
void extendedMethod3(),
}
+typedef map<ThriftTest.UserId, map<NamespacedTest.UserId, list<TestStruct2> > > ComplexMapType
+
+struct ComplexMapStruct {
+ 1: ComplexMapType complex,
+}
+
+service ComplexMapService {
+ ComplexMapStruct transformMap(1: ComplexMapStruct input),
+}
+