Skip to content

[flutter_tools] add --null-assertions flag for debugging with null safety#63416

Merged
fluttergithubbot merged 4 commits into
flutter:masterfrom
jonahwilliams:add_null_assertions
Aug 11, 2020
Merged

[flutter_tools] add --null-assertions flag for debugging with null safety#63416
fluttergithubbot merged 4 commits into
flutter:masterfrom
jonahwilliams:add_null_assertions

Conversation

@jonahwilliams

Copy link
Copy Markdown
Contributor

Description

Make the flag available as an opt-in. A follow up PR will enable this for the flutter CI and fix the known test failures. This will insert additional null checks between null-safe and on-null safe libraries, with then intention of catching violations before all code has migrated to null safety

This flag must be off by default because it breaks a non-trivial amount of existing code

#61042

@flutter-dashboard flutter-dashboard Bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 10, 2020
String flags = debuggingOptions.dartFlags ?? '';
if (debuggingOptions.nullAssertions) {
final String separator = flags.isEmpty ? '' : ',';
flags += '$separator--null_assertions';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is making a list and joining too clunky?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Very difficult for my sleepy brain 🤣

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just wanted you to know that I understand the fence post problem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

'--observatory-port=60700',
'--start-paused',
'--dart-flags="--foo"',
'--dart-flags="--foo,--null_assertions"',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there a test that's just --null_assertions without a --foo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a unit test that tests various flag combinations in computeDartVmFlags

@jmagman jmagman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

);
argParser.addFlag(FlutterOptions.kNullAssertions,
help:
'Whether to perform additional null checks on the boundaries of null safe and '

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe 'Perform additional null checks...

@fluttergithubbot fluttergithubbot merged commit c86d090 into flutter:master Aug 11, 2020
@jonahwilliams jonahwilliams deleted the add_null_assertions branch August 11, 2020 19:16
mingwandroid pushed a commit to mingwandroid/flutter that referenced this pull request Sep 6, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants