Skip to content
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

Make use of field promotion in SDK libraries #52982

Closed
stereotype441 opened this issue Jul 19, 2023 · 0 comments
Closed

Make use of field promotion in SDK libraries #52982

stereotype441 opened this issue Jul 19, 2023 · 0 comments
Labels
area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …).

Comments

@stereotype441
Copy link
Member

https://dart-review.googlesource.com/c/sdk/+/314500 refactors several places in the SDK to avoid having the build fail due to "unnecessary !" warnings when we enable the language feature inference-update-2 (which provides support for promotion of final private fields). For example, it changes:

Directory createDirectory(String path) {
  if (_createDirectory != null) return _createDirectory!(path);
  if (_previous != null) return _previous!.createDirectory(path);
  return super.createDirectory(path);
}

to

Directory createDirectory(String path) {
  if (_createDirectory != null) return _createDirectory!(path);
  var previous = _previous;
  if (previous != null) return previous.createDirectory(path);
  return super.createDirectory(path);
}

After interface-update-2 has been enabled, we should consider refactoring this to:

Directory createDirectory(String path) {
  if (_createDirectory != null) return _createDirectory!(path);
  if (_previous != null) return _previous.createDirectory(path);
  return super.createDirectory(path);
}

(note the absence of the ! in _previous.createDirectory).

@stereotype441 stereotype441 added the area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …). label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-sdk Use area-sdk for general purpose SDK issues (packaging, distribution, …).
Projects
None yet
Development

No branches or pull requests

1 participant