Annotate Mockito#{mock,spy}(T... reified) with @SafeVarargs#2866
Merged
TimvdLippe merged 1 commit intomockito:mainfrom Jan 14, 2023
PicnicSupermarket:improvements/safe-varargs-mock-type-detection
Merged
Annotate Mockito#{mock,spy}(T... reified) with @SafeVarargs#2866TimvdLippe merged 1 commit intomockito:mainfrom PicnicSupermarket:improvements/safe-varargs-mock-type-detection
Mockito#{mock,spy}(T... reified) with @SafeVarargs#2866TimvdLippe merged 1 commit intomockito:mainfrom
PicnicSupermarket:improvements/safe-varargs-mock-type-detection
Conversation
This avoids "Unchecked generics array creation for varargs parameter" warnings at the call site.
Stephan202
commented
Jan 14, 2023
Comment on lines
+1935
to
1936
| @SafeVarargs | ||
| public static <T> T mock(T... reified) { |
Contributor
Author
There was a problem hiding this comment.
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 ReportBase: 84.76% // Head: 84.76% // No change to project coverage 👍
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
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This avoids "Unchecked generics array creation for varargs parameter" warnings at the call site.