-
Notifications
You must be signed in to change notification settings - Fork 746
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
UnnecessaryBoxedAssignment: avoid CCE on method reference #4157
UnnecessaryBoxedAssignment: avoid CCE on method reference #4157
Conversation
56ef965
to
73dc358
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not really investigate what it would take to support method references, but I suspect that would be a check all by itself, if such a thing would make sense at all.
@@ -76,4 +78,8 @@ Integer positive_wrappedAgain(int aInteger) { | |||
a = Integer.valueOf(aInteger); | |||
return Integer.valueOf(a); | |||
} | |||
|
|||
void negative_methodReference() { | |||
Function<String, Boolean> toBoolean = Boolean::valueOf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the fix this triggers:
java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCMemberReference cannot be cast to class com.sun.source.tree.MethodInvocationTree (com.sun.tools.javac.tree.JCTree$JCMemberReference and com.sun.source.tree.MethodInvocationTree are in module jdk.compiler of loader 'app')
at com.google.errorprone.bugpatterns.UnnecessaryBoxedAssignment.matchCommon(UnnecessaryBoxedAssignment.java:72)
at com.google.errorprone.bugpatterns.UnnecessaryBoxedAssignment.matchVariable(UnnecessaryBoxedAssignment.java:64)
No description provided.