thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Yegge <steve.ye...@gmail.com>
Subject Nested lists generate invalid Objective-C code
Date Wed, 28 Oct 2015 16:18:42 GMT
Hi folks,

This is my first post, and I'm not sure about the protocol for bug
reporting.

Objective-C generics apparently do not support nesting.  E.g., adding this
line to any method:

    NSArray<NSArray<NSString *>> *myArray = [NSArray new];

Will result in XCode issuing the error:  Type argument 'NSArray<NSString
*>' is neither an Objective-C object nor a block type

The latest Thrift compiler (1.0.0-dev, pulled from head yesterday)
transforms something like this

  1: list<list<string>> foo

into an Objective-C declaration like this

  @property (strong, nonatomic) NSMutableArray<NSArray<NSString *>> * foo;

which results in an XCode compile error like the one above.

Until ObjC supports nested generics, I'd guess that the best solution would
be to limit the type conversion recursion to depth 1, yielding something
like so:

  @property (strong, nonatomic) NSMutableArray<NSArray> * foo;

I haven't tested it, but I would assume this problem applies to any nested
collection types.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message