Skip to content

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Feb 16, 2022

fixes flutter/flutter#98452

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@gaaclarke gaaclarke force-pushed the nullable-return-types branch from d5e4b22 to 77a4216 Compare February 16, 2022 00:39
@gaaclarke gaaclarke marked this pull request as ready for review February 16, 2022 00:56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

details isn't required, so this line can just be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Same in the existing code just below; where we can trivially make the generated code less verbose we should do so.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that this is before the if line in the generating code was super confusing to me in trying to follow this. I think it would be helpful to make each of the if/else if/else blocks a local variable, declared in order, and then use all three below, so that generated code sequence is in order in this code.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Longer term than this PR: I think the complexity has gotten to the point where we should very strongly consider using a templating system, like we do for the generated plugin registrants in flutter_tool. We could likely make it much easier to read the to-be-generated code that way.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swapped everything now so it shows up in the correct location now. Something like mustache might help. Its hard to guess the ROI right now though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullCheckIfApplicable? It's not always a null check.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do a comment like the one above for the fragment that this is responsible for making?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference: it would be helpful to separate a refactor that makes ~the entire function into a diff from functional changes. I have no idea what actually changed in this code beyond the indentation changes from the inner function extraction.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. I know you asked for it in the past and I accidentally squashed it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/when/only when/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@gaaclarke gaaclarke force-pushed the nullable-return-types branch from 77a4216 to 08be1d4 Compare February 17, 2022 18:51
: 'return ($accessor as $returnType$nullTag)$unwrapper$castCall;';
// On iOS we can return nil from functions to accommodate error
// handling. Returning a nil value and not returning an error is an
// exception.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment got separated from the code it's about (which is now at line 226).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return type.isVoid
? 'void(^)(NSError *_Nullable)'
: 'void(^)(${objcType.ptr.trim()}, NSError *_Nullable)';
: 'void(^)(${objcType.ptr.trim()}$nullable, NSError *_Nullable)';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this have to be nullable in all cases, just like the actual synchronous return value, for the case where there's an error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good call.

// found in the LICENSE file.
//
// Autogenerated from Pigeon (v1.0.15), do not edit directly.
// Autogenerated from Pigeon (v1.0.18), do not edit directly.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is updating the version to 19.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// found in the LICENSE file.
//
// Autogenerated from Pigeon (v1.0.15), do not edit directly.
// Autogenerated from Pigeon (v1.0.18), do not edit directly.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and in other files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gaaclarke gaaclarke merged commit 14b7d46 into flutter:main Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement nullable return values

2 participants