-
Notifications
You must be signed in to change notification settings - Fork 166
Incorrect type in mocks with analyzer
5.x
#612
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
This worked fine for me following these instructions - I confirmed I got the latest verison of all packages as well. What flutter version are you on, and are all your other deps fully upgraded? Fwiw I tested with:
|
I also cannot reproduce, with an older version of Flutter, and with the latest on |
Reproducible for us on:
mockito: ^5.3.2 |
I'm on
|
I tried on 3.7.3 and it didn't reproduce for me. Can you confirm you are also running a |
Okay, it turns out I thought I'd run exactly those steps but hadn't, and it is something about stale artifacts. The real STR is to do: 1, 2, 4, 3, 4, 5 That will give the bad output.
Sorry for the confusion. I'm not sure if this still qualifies as a bug, or if "delete absolutely everything" is a required step when updating analyzer. |
It should not be a required step, no, so we should leave this open. |
Ok, I was finally able to reproduce this - the critical difference is when updating the pigeon package, if you only run a Given it does work with the latest versions I am going to close the issue, if you can confirm that works for you as well. |
In particular build_resolvers 2.1.0 is probably necessary, it has a changelog entry that reads "Return all SDK libraries in Resolver.libraries, making the implementation consistent with the documentation.". That seems likely to be the fix you need. |
We can close it; I do wonder if other people will do the same thing since Maybe |
I feel very strongly that packages should not update their constraints on other packages just to try and ensure that users get a certain bug fix. Especially if that package has no pre-existing dependency on the package. This is the path towards version lock and it would be a death spiral for the ecosystem. I am not sure why running Essentially, |
I generally agree, and we mostly don't do this in federated plugins. I thought it might be worth considering here since the failure is so bizarre and hard to understand, but I don't feel strongly about it.
I suspect (based on what I see in flutter/flutter issue reports) that a lot of users never type either, and just let VS Code run it for them when they modify their pubspec.yaml. (People ~never getting updates to transitive dependencies is definitely a real problem in the broader community.) |
Yeah that does make sense, and it is probably the right thing for a tool to do. But we probably are missing some tooling that would notify users when their versions are getting out of date? |
Perhaps this is the bug that we should try to fix? |
As an illustrative example that just came in, in case anyone is curious: flutter/flutter#121928 is a case where someone has transitive dependencies (implementation packages of a federated plugin) that are at least two years old. |
I do think there is definitely some piece of tooling here that is missing, to nudge people to upgrade their deps. |
We're having a strange issue with
mockito
generating the wrong types inwebview_flutter_android
when trying to updateanalyzer
. I have tried to make a minimal repro case, but haven't been able to recreate the problem so far so filing with what I have for now.STR:
pubspec.yaml
to change thepigeon
dependency topigeon: ^9.0.0
. (This allowsanalyzer
to resolve to 5.7.1 instead of 4.x.) thenflutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter test test/android_webview_test.dart
The test fails to compile:
There are similar problems with a
Future<Size>
.If you skip step 3, everything is fine, and the generated code has the correct type. Comparing the lock files, it's just analyzer that changes between them (and pigeon of course, but I'm not re-running Pigeon generation, so its version is irrelevant).
I tried adding
Offset
to the@GenerateMocks
list inandroid_webview_test.dart
to see if that would help, and that causes (with 5.x only):Invalid @GenerateMocks annotation: The GenerateMocks "classes" argument is missing, includes an unknown type, or includes an extension
.I made a simple project that just has a class with a
Future<Offset>
method in it, and couldn't reproduce this, but I haven't yet been able to figure out what the important difference is.The text was updated successfully, but these errors were encountered: