-
Notifications
You must be signed in to change notification settings - Fork 160
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 PostExpectation generic. #98
Comments
Sounds good. Maybe specifically Answering needs to be type annotated? https://github.com/dart-lang/mockito/blob/master/lib/src/mock.dart#L605 |
I'm not sure if that will help. We need to have a return type here: https://github.com/dart-lang/mockito/blob/master/lib/src/mock.dart#L320 |
Ah I see. Do you see any way to type the T in |
I think the type should be coming from here: https://github.com/dart-lang/mockito/blob/master/lib/src/mock.dart#L744 |
Yeah I can see it. Sounds good, I'll accept a PR. |
Fixed with #101 |
An error cropping up while migrating tests to Dart 2.0 semantics is having invalid return types for
thenAnswer
which cause runtime issues.For example consider the class Foo:
Set up the mock for Foo as follows:
The above will currently run without issue in the VM. However, the return type of
thenAnswer
is invalid as it should be returningFuture<B>
instead of the rawB
value. I believe we can catch these errors through analysis.when
usesPostExpectation
which can be made generic. This will allow us to enforce the return type ofthenAnswer
accordingly.The text was updated successfully, but these errors were encountered: