Skip to content

Commit

Permalink
scrooge-generator: Resolve self referencing types.
Browse files Browse the repository at this point in the history
Problem

Scrooge currently doesn't support self-referencing types. This is
useful for a number of cases.

Solution

Change the type resolver's scope to include the current type. Add unit
tests.

Result

Self-referencing types no longer result in TypeNotFoundException.
This should resolve #243 and
partially resolve #160. This
change doesn't yet support recursive types which is needed to fully
resolve #160.

This should be a backward compatible change since all the thrift files
that are resolved correctly now will continue to get resolved
correctly.

One caveat though is that we don't enforce the self-reference type to
be optional or collection type. We just depend on the generated`
language's compiler to enforce that (i.e. we expect that compiler to
generate an error if a self-referencing type is specified as
required).

Signed-off-by: Kevin Oliver <koliver@twitter.com>

RB_ID=873802
  • Loading branch information
pinsri authored and jenkins committed Sep 26, 2016
1 parent 801cbf4 commit 2271a73
Show file tree
Hide file tree
Showing 11 changed files with 816 additions and 36 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ as it is included in Scrooge's user's guide.
4.x
-----

- Add support for self-referencing types from `pinsri` via
https://github.com/twitter/scrooge/pull/244 ``RB_ID=``

- scrooge: Remove unmaintained bin/ directory. ``RB_ID=873411``

4.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ struct Request {
1: list<string> aList,
2: set<i32> aSet,
3: map<i64, i64> aMap,
4: optional Request aRequest,
5: list<Request> subRequests
}

struct Response {
Expand Down
Loading

0 comments on commit 2271a73

Please sign in to comment.