-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swift: Fix for @ProtoDefaulted #2706
Conversation
fcabc25
to
e0dd0b2
Compare
import XCTest | ||
@testable import Wire | ||
|
||
final class ProtoEnumTests: XCTestCase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are new tests for other work that happened in v4.9.2.
@@ -186,7 +186,8 @@ class SwiftGenerator private constructor( | |||
if (type == ProtoType.ANY) return false | |||
if (isMessage) { | |||
val messageType = schema.getType(type!!) as MessageType | |||
return messageType.supportsEmptyInitialization | |||
|
|||
return messageType.supportsEmptyInitialization && messageType.fields.isNotEmpty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix/change. I believe it is the correct fix overall if for any reason we cannot load the fields
of a message we do not know whether we can provide a default value for it.
Across module boundaries,
Message.fields
is often (always?) empty. When that happens, we can't correctly know that we want@ProtoDefaulted
or not. Given it's unknowable in the current context, it chooses not to emit them.