-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Customer-reported issue with NNBD migration tool #44280
Comments
Hi @escamoteur, I cloned fluttercommunity/get_it@dd56ba9 and was able to reproduce your problem. Thanks so much for your bug report! It looks like there are a number of coding patterns in the get_it package that the migration tool stumbles on. I'll spend some time investigating them and file separate issues for each one. In the meantime, your best bet to work around the issues is probably to use the migration tool's "hint" feature to tell it where it's come to incorrect conclusions. You can use T/*!*/ get<T>({String instanceName, dynamic param1, dynamic param2});
Future<T>/*!*/ getAsync<T>({String instanceName, dynamic param1, dynamic param2});
T/*!*/ call<T>({String instanceName, dynamic param1, dynamic param2}); You can either add those I hope that helps! |
Thanks, I was pretty sure that my get_it is a good test candidate :-) |
@stereotype441 there should be an explanation in the tool what the /!/ and /?/ are for. I had no idea that I can set hints this way. |
after I did apply refactoring. In VS code I get always errors from the analyser. it seems that there is something wrong.
you can find this state of the sources here |
Aha, it looks like the tool added the necessary import to make this work, but it erroneously added it to the top of (The tool should have also adjusted your pubspec to add a dependency on the |
Agreed, this is definitely something the tool could do better. This is covered by #38470. |
We did provide an explanation, but I guess it wasn't easy enough to find. If you click on the "help" button in the upper right corner of the tool, it takes you to https://github.com/dart-lang/sdk/blob/master/pkg/nnbd_migration/README.md, which explains about the hints. @kwalrath do you think we should make some updates to https://github.com/dart-lang/sdk/blob/master/pkg/nnbd_migration/README.md to link it up better with other public-facing documentation of the migration tool? |
I think it wasn't clear what the hint does. Also what happens if a hint is turned red? Thanks for your reply. Would be awesome if you could have a look at the other issues above especially the continously crashing analyser. Which makes further fixing of problems almost impossible |
The hint The hint ( Hopefully @kwalrath (who is in charge of documentation) will have further ideas about how to make this clearer so that other users don't stumble on it. The migration tool uses red to indicate text that is going to be removed when the migration is performed. So when you add a Perhaps some of the reason this was confusing is that when you first click on the "add hint" buttons, the text isn't red yet; it only becomes red later after you've re-run migration. I've filed #44311 to track this issue. |
@scheglov @devoncarew @srawlins could one of you look at the analyzer crash? |
exactly that. Maybe also think about using another color than red, because I associate it with an error |
No, that isn't a problem, it's not a part file.
|
@escamoteur Regarding the crash. I don't see any stack trace in the messages. Could you point at one, or (better) provide more details to to reproduce one? |
|
Thank you, I can reproduce it. |
Attention, in this case I don't use any |
@escamoteur Yes, my change does not fix this migration issue, it only fixes the analyzer crash. But the code does use parts. I'm looking into library get_it;
import 'dart:async';
import 'package:async/async.dart';
import 'package:meta/meta.dart';
part 'get_it_impl.dart'; And the part file import 'package:collection/collection.dart' show IterableExtension;
part of 'get_it.dart'; And this |
…LIBRARY_INTO_NULL_SAFE. Bug: #44280 Change-Id: I6a8ef25deaedc55ef33e83ba7614f23fd56fe788 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174220 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov Sorry, I really forgot that I added the part stuff some time ago. |
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. |
I'm trying to migrate my get_it package but I have some issues. The migrate tool want's to make types nullable that are not necessary. Because the tool does not excepts code that has already null safe operators like 'late' or '!' you can't help the tool.
It would be good if you could deselect proposed changes but still be able to let the other changes be done.
I also observed several added casts, that are not really necessary.
If you want to try it with get_it yourself, the type 'T' of
get
,getAsync
andcall
could be defined as 'extends Object` which I tried but still the tool wants to change the return type into a nullable TIf you are interested, we could do a walkthrough together. Just ping me on Twitter @thomasburkhartb
Dart SDK version: 2.12.0-29.10.beta
Thanks for filing!
The text was updated successfully, but these errors were encountered: