Skip to content

Proto3 Optional fields should be Swift optionals #1114

@wilg

Description

@wilg

I see that there is support for Proto3 optionals (#1096) however as far as I can tell the generated code does not actually expose these as Swift optionals:

    public var email: String {
      get {return _email ?? String()}
      set {_email = newValue}
    }
    /// Returns true if `email` has been explicitly set.
    public var hasEmail: Bool {return self._email != nil}
    /// Clears the value of `email`. Subsequent reads from it will return its default value.
    public mutating func clearEmail() {self._email = nil}

This seems to defeat a lot of the ergonomics that would be possible if these came through directly as Swift optionals. If there's some backwards compatibility issues, I'm happy to enable some flag for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions