Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
0.12.0, 0.13.0, 0.14.0, 0.15.0
-
None
-
None
Description
When a thrift typedef is placed after a struct in which that typedef is used for a field, the generated Golang code does not assign the defined type but rather the underlying type in its field definition.
Example:
struct MyFirstStruct { 1: required MyTypedef my_typedef; } typedef i32 MyTypedef; struct MySecondStruct { 1: required MyTypedef my_typedef; }
Generates the code (with elided parts):
type MyTypedef int32 ... // Attributes: // - MyTypedef type MyFirstStruct struct { MyTypedef int32 `thrift:"my_typedef,1,required" db:"my_typedef" json:"my_typedef"` } ... // Attributes: // - MyTypedef type MySecondStruct struct { MyTypedef MyTypedef `thrift:"my_typedef,1,required" db:"my_typedef" json:"my_typedef"` }
Note how the second struct uses the defined type but the first struct uses the underlying type. Since the first struct is able to define the underlying type as the type of the field, it's clearly resolving the typedef but not using it for some reason.