Skip to content

Conversation

@Abhishek01039
Copy link
Contributor

part of #84014

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Jun 6, 2021
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla bot added the cla: yes label Jun 6, 2021
Comment on lines 5 to 6
void methodThatAcceptsNonNull(int? x) {
print(x! + 2);
Copy link
Member

Choose a reason for hiding this comment

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

Why the added ? and ! here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are trying to pass null here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

@goderbauer we need to pass null here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused. Isn't the point of the function that the method only accepts non-null values? In other words, just removing the comment // @dart = 2.12 should be enough after reverting these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @shihaohong
here we need to pass null value. So how should I deal with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@Abhishek01039 can you explain why we need to pass a null value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Piinks we need to assert here but I think we can remove this file dev/integration_tests/web/lib/null_assert_main.dart

@Piinks Piinks added a: null-safety Support for Dart's null safety feature c: tech-debt Technical debt, code quality, testing, etc. labels Jun 9, 2021
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Can you check the analyzer here? It looks like it is unhappy.

@Abhishek01039
Copy link
Contributor Author

Yes because we are trying to pass a null value to a non-nullable variable.

 error • The argument type 'Null' can't be assigned to the parameter type 'int'

@Piinks

@darrenaustin
Copy link
Contributor

@jonahwilliams it looks like you added these files as part of #61114. This PR is part of an effort to finish migrating everything to null safety. However, it would appear that these files only make sense to test with null safety turned off. Should we just leave them untouched because we still need them, or can we remove them now that everything is being moved to null safety?

@jonahwilliams
Copy link
Contributor

Only a very small % of the Dart/Flutter ecosystem is migrated to null safety, so we still need to test this until a hypothetical Dart 3.0 / Removal of null unsafe code

@darrenaustin
Copy link
Contributor

Only a very small % of the Dart/Flutter ecosystem is migrated to null safety, so we still need to test this until a hypothetical Dart 3.0 / Removal of null unsafe code

Ok, sounds good. @Abhishek01039 thanks so much for helping with this, but it looks like we should just leave these files as is. I will go ahead and close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: null-safety Support for Dart's null safety feature c: contributor-productivity Team-specific productivity, code health, technical debt. c: tech-debt Technical debt, code quality, testing, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants