Das Shuvomay created THRIFT-5489:
------------------------------------
Summary: Generated Go Struct Fields Use Underlying Type Instead of
Defined Type If thrift Typedef Comes After
Key: THRIFT-5489
URL: https://issues.apache.org/jira/browse/THRIFT-5489
Project: Thrift
Issue Type: Bug
Components: Go - Compiler
Affects Versions: 0.15.0, 0.14.0, 0.13.0, 0.12.0
Reporter: Das Shuvomay
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:
{code:java}
struct MyFirstStruct {
1: required MyTypedef my_typedef;
}
typedef i32 MyTypedef;
struct MySecondStruct {
1: required MyTypedef my_typedef;
} {code}
Generates the code (with elided parts):
{code:java}
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"`
} {code}
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.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)