-
Notifications
You must be signed in to change notification settings - Fork 51
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
[ObjC] Mark NSObject init / new as unavailable for records with any fields #28
[ObjC] Mark NSObject init / new as unavailable for records with any fields #28
Conversation
Hi @jgavris thanks for the PR. I don't completely understand the proposed changes. We currently do not generate default (no parameter) init method, this makes sure the caller initializes records with proper initial values. Are you proposing that we should add a default init method, but hide it from swift if it has nonnull members? Wouldn't this still expose potential invalid objects to ObjC uses? |
My main concern is that this is a breaking change and it may break some existing code. However, if I understand correctly, if any code is broken by this change, then that code itself is problematic and should be fixed. |
There will likely be code that is 'accidentally' using the |
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.
looks good once you re-run codegen in the other directories.
@jgavris do you still intend to merge this PR? Like I said above, we need to re-run codegen in all sub-project directories and fix the documentation otherwise I think this is good to go. |
@finalpatch Yes, thanks for the feedback. I was going to suggest adding your comment in #28 (comment) to the CI workflow (and test step that ensures they are not dirty), so that future contributions are 'clean'. |
Thanks. Yeah it's a bit annoying we have to check in the codegen changes. I'm not sure if the CI workflow is the right place for it. We are exploring way to run the codegen as a part of the bazel build process, hopefully this will make the manual codegen step no longer necessary. |
f2969cb
to
b6a8a16
Compare
b6a8a16
to
cbe797e
Compare
SGTM. It's a bit tricky to get Bazel to modify / generate files as part of the build https://shantanugoel.com/2020/05/03/bazel-rule-auto-generate-files-compile-time/ |
Blocked by #27 for full test suite, but passes.
[NSObject init]
or[NSObject new]
) is called (on any record withoptional
fields), which can cause an unexpectedly unwrapped optionalnil
in Swift code. Mark these as unavailable to hide them from Swift../ci/generate.sh
step as an intermediate check to make sure that all the example test files are 'clean' before running the test suite.