Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3029

Getters for fields defined with uppercase names do not work

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Won't Do
    • Affects Version/s: 0.9.2
    • Fix Version/s: 0.13.0
    • Component/s: Cocoa - Compiler
    • Labels:
      None

      Description

      Using a thrift file such as:

      foo.thrift
      struct Foo {
        1: required i32 Bar;
        2: required i32 baz;
      }
      

      The generated Objective-C object, "baz" will have working getters but "Bar" will not. For example, after setting bar to 5 and baz to 9, I get the following output depending on the syntax:

      [foo bar] => 0
      [foo Bar] (private method invoked by performSelector) => 5
      foo.bar => 0
      foo.Bar => 0
      foo.baz => 9
      

      The problem is that the generated header specifies a lowercase getter:

      @property (nonatomic, getter=bar, setter=setBar:) int32_t Bar;
      

      Whereas the .m file uses uppercase:

      - (int32_t) Bar {
        return __Bar;
      }
      

      When the Objective-C compiler sees that there is no lowercase getter implementation provided, it automatically generates one (this is supposed to be a convenience of the @property syntax). So effectively, two getters are defined: a lowercase one that does not work, and an uppercase one that does work but is private.

      As a workaround one can define all their fields beginning with a lowercase letter, if possible.

        Attachments

          Activity

            People

            • Assignee:
              jking3 James E. King III
              Reporter:
              wes Wes Henderson
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: