Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

convert zircon and fuchsia to null-safety #20577

Merged
merged 1 commit into from
Aug 18, 2020

Conversation

chaselatta
Copy link
Contributor

Description

Changes the --nnbd-weak flag to --nnbd-agnostic and migrates the native zircon and fuchsia packages to be null safe. This will allow us to start using nullability features inside of fuchsia.

Related Issues

fxb/55746

Tests

Tested by rolling the changes manually into the fuchsia tree and running the workstation product. Change works with the current state of not having the nullability experiment enabled as well as later adding it and writing a simple library which uses nullability annotations.

@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.

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

@@ -25,7 +24,7 @@ class _Logger {
}

@pragma('vm:entry-point')
String _rawScript;
late String _rawScript;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the distinction between the late vm entrypoint fields and the nullable ones, is this guaranteed to be set, while the others might still be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah... all of the other entry points could be null since they are set by the engine and do have real reasons for being null. The view ref, for example, is only available for things that need a UI. The other entry points will cause the program to not function well when they are null be we currently rely on them being null for host side tests.

I couldn't find a valid reason why this value would be null. If there is one I can update this to be ? instead of late.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it comes down to what we want to do with the _scriptUri function below. Is there a valid default if this value is null?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably no reasonable default, so if it is always going to be set then late is fine.

Copy link
Contributor

@arbreng arbreng left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM for platform dill changes, probably someone more familiar with the fuchsia dart:* libraries should take a look too

Copy link
Contributor

@alexmarkov alexmarkov left a comment

Choose a reason for hiding this comment

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

LGTM with a few comments.

@@ -88,7 +95,7 @@ class WriteResult extends _Result {

@pragma('vm:entry-point')
class GetSizeResult extends _Result {
final int size;
final int? size;
Copy link
Contributor

Choose a reason for hiding this comment

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

This migration to null safety looks good.

However, if it is idiomatic to check status before using other fields of the result classes, then we might also consider introducing getter which would return non-nullable value, as it is much easier to work with non-nullable values. Something along the lines:

class GetSizeResult extends _Result {
  final int? _size;
  int get size => _size!;

  @pragma('vm:entry-point')
  const GetSizeResult(final int status, [this._size]) : super(status);

  @override
  String toString() => 'GetSizeResult(status=$status, size=$_size)';
}

This can be a breaking change, so it might make sense to do this in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is actually a really good point. Right now folks would have to check status or else they would crash when they tried to check the size. This would probably be the correct time to migrate this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

@ianloic ianloic left a comment

Choose a reason for hiding this comment

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

LGTM

@chaselatta chaselatta merged commit 17e1ae4 into flutter:master Aug 18, 2020
@chaselatta chaselatta deleted the null-safe-packages branch August 18, 2020 20:15
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 18, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 19, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 19, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants