Skip to content
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

Annotate Mockito#{mock,spy}(T... reified) with @SafeVarargs #2866

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/org/mockito/Mockito.java
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,7 @@ public class Mockito extends ArgumentMatchers {
* @return mock object
* @since 4.9.0
*/
@SafeVarargs
public static <T> T mock(T... reified) {
Comment on lines +1935 to 1936
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a sense there is already a test for this case, but as Mockito currently doesn't compile with something like options.compilerArgs << "-Xlint:unchecked" << "-Werror", the build currently doesn't fail on it. The changes in this PR are relevant for users that do compile with those flags.

if (reified.length > 0) {
throw new IllegalArgumentException(
Expand Down Expand Up @@ -2161,6 +2162,7 @@ public static <T> T spy(Class<T> classToSpy) {
* @return spy object
* @since 4.9.0
*/
@SafeVarargs
public static <T> T spy(T... reified) {
if (reified.length > 0) {
throw new IllegalArgumentException(
Expand Down