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

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

merged 1 commit into from Jan 14, 2023

Conversation

Stephan202
Copy link
Contributor

This avoids "Unchecked generics array creation for varargs parameter" warnings at the call site.

This avoids "Unchecked generics array creation for varargs parameter"
warnings at the call site.
Comment on lines +1935 to 1936
@SafeVarargs
public static <T> T mock(T... reified) {
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.

@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2023

Codecov Report

Base: 84.76% // Head: 84.76% // No change to project coverage 👍

Coverage data is based on head (26709a5) compared to base (adf528d).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2866   +/-   ##
=========================================
  Coverage     84.76%   84.76%           
  Complexity     2867     2867           
=========================================
  Files           327      327           
  Lines          8780     8780           
  Branches       1068     1068           
=========================================
  Hits           7442     7442           
  Misses         1064     1064           
  Partials        274      274           
Impacted Files Coverage Δ
src/main/java/org/mockito/Mockito.java 96.42% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@TimvdLippe TimvdLippe left a comment

Choose a reason for hiding this comment

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

Thanks!

@TimvdLippe TimvdLippe merged commit acddbbc into mockito:main Jan 14, 2023
@Stephan202 Stephan202 deleted the improvements/safe-varargs-mock-type-detection branch January 15, 2023 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants