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
Add back InvocationOnMock.getArgument<T>(int, Class<T>) #1609
Comments
For more information see the error-prone bugpattern: https://errorprone.info/bugpattern/TypeParameterUnusedInFormals |
@mockitoguy WDYT? I think it makes sense to have a simple API for local assignments or in return statements, but we would still need the Class to be explicit. |
Looking... |
Good idea! Few suggestions:
Nice catch. |
Awesome, thanks for the quick response! Will open a PR today 😄 |
Also add `@NotExtensible` to several of our interfaces to document they are not intended to be subclassed. Fixes #1609
Instead of using the reintroduced invocation.<Runnable>getArgument(0).run() That's admittedly less obvious, but does keep the API smaller. Has this been considered? |
While that does work as well, I think consistency with the old API as well as the readability of the former vs the latter would still lead me to conclude that reintroducing is the appropriate solution. |
In #365 we replaced the existing
getArgumentAt<T>(int, Class<T>)
API with the currentgetArgument(int)
API. However, when integrating this change within Google, we ran into numerous issues.An example:
gets rewritten to
This does not compile, as the generic parameter is erasured to
Object
and thus does not have therun
method.Therefore, I would propose adding back an overload to
getArgument
that allows you to specify theClass
. In general, users would not need this inside a variable assignment, but do need it in all other cases.The text was updated successfully, but these errors were encountered: