-
Notifications
You must be signed in to change notification settings - Fork 1.7k
'dart migrate' throws Exception: type '_NullAwareAccessContext<PromotableElement, DartType>' is not a subtype of type '_TryContext<PromotableElement, DartType>' in type cast #44349
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
Comments
@knaeckeKami thanks for the bug report! I was able to reproduce your bug with changenotifier_benchmark as of knaeckeKami/changenotifier_benchmark@4679f8f. To help us prioritize, were you able to make reasonable progress using the |
Yes, with I had issues with: migration of
to List<_Listener>? _listeners = List<_Listener>(); ( (Multiple instances of this error, but easily fixed) Migration of bold(resultsByApproach[approach]
.map((e) => e.time)
.fold(0, (a, b) => a + b)
.toString()) to bold(resultsByApproach[approach]!
.map(((e) => e.time) as _ Function(TestResult))
.fold(0, ((dynamic a, b) => a + b) as _ Function(_, dynamic))
.toString()) With |
Ok, good to know, thanks.
Glad this was easily fixed. FYI, we're hoping to improve the migration tool's handling of the
Interesting: that's not one I've seen before. I filed #44357 to track it. |
Actually, there's another issue :) The tool migrated results.toMultiMap(keyFunc: (r) => r.approach, valueFunc: (v) => v); to final resultsByApproach =
results.toMultiMap(keyFunc: ((r) => r.approach) as String Function(TestResult), valueFunc: (v) => v); (print_table.dart, line 12). This throws an exception at runtime: |
This looks very similar to the issue discussed in #44345 (comment), which was fixed in e047dd6. I believe what's happening is that the presence of Alternatively, you can try running the migration tool again with a more recent build that contains the bug fix (Dart version 2.12.0-77.0.dev or higher). |
Yeah, removing the cast works, of course, it just wanted to report the issue, but great to see that it's already fixed on master. |
@stereotype441 @srawlins this is currently marked P1, is this still an issue, and if so do we plan to fix it? |
I'm dropping priority to P2 considering that |
@stereotype441 Are we still targeting this for January? |
At this point it looks unlikely that we'll be able to get to this in time for the stable release. Removing from the milestone. |
Unassigning myself because I'm not actively working on the migration tool right now. |
When I run 'dart migrate' on a small Flutter project, I get this output with an Exception thrown:
How to reproduce
git clone -b nullsafety --single-branch https://github.com/knaeckeKami/changenotifier_benchmark.git
cd changenotifier_benchmark/
dart pub get
dart migrate
The text was updated successfully, but these errors were encountered: