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

Migration tool should call out inserted casts of function literals as questionable. #40471

Closed
stereotype441 opened this issue Feb 5, 2020 · 1 comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). NNBD Issues related to NNBD Release P3 A lower priority bug or feature request

Comments

@stereotype441
Copy link
Member

As of https://dart-review.googlesource.com/c/sdk/+/134504, there are certain situations where the migration tool may insert a type cast that is guaranteed to fail. For example:

void f(int/*!*/ Function(int) callback) {
  callback(null);
}
int g(int x) => x;
void test() {
  f(g);
}

gets migrated to:

void f(int/*!*/ Function(int?) callback) {
  callback(null);
}
int? g(int? x) => x;
void test() {
  f(g as int Function(int?)); // BAD
}

In this sort of situation, user intervention is required to figure out how the code should be migrated. The tool should either highlight the cast as questionable.

Alternatively, we could either:

  • change the migration tool so that it doesn't generate the questionable cast, and the user is alerted to the problem by the fact that the migrated code has a compile-time error, OR
  • change the migration tool so that it inserts a function literal with a null check, i.e. f((x) => g(x)!); in this example.
@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-nnbd-migration NNBD Issues related to NNBD Release labels Feb 5, 2020
@srawlins srawlins added the P2 A bug or feature request we're likely to work on label Sep 8, 2020
@srawlins srawlins added P3 A lower priority bug or feature request and removed P2 A bug or feature request we're likely to work on labels Oct 5, 2020
@stereotype441 stereotype441 added area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). and removed analyzer-nnbd-migration area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 16, 2020
@stereotype441
Copy link
Member Author

As of 1c7fe71, the null safety migration tool has been removed from active development and retired. No further work on the tool is planned.

If you still need help, or you believe this issue has been closed in error, please feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). NNBD Issues related to NNBD Release P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

2 participants