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

UnnecessaryBoxedAssignment: avoid CCE on method reference #4157

Conversation

Stephan202
Copy link
Contributor

No description provided.

@Stephan202 Stephan202 force-pushed the sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment branch from 56ef965 to 73dc358 Compare October 21, 2023 12:10
Copy link
Contributor Author

@Stephan202 Stephan202 left a 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;
Copy link
Contributor Author

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)

copybara-service bot pushed a commit that referenced this pull request Oct 23, 2023
Fixes #4157

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4157 from PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment 73dc358
PiperOrigin-RevId: 575469406
copybara-service bot pushed a commit that referenced this pull request Oct 23, 2023
Fixes #4157

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4157 from PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment 73dc358
PiperOrigin-RevId: 575469406
copybara-service bot pushed a commit that referenced this pull request Oct 23, 2023
Fixes #4157

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4157 from PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment 73dc358
PiperOrigin-RevId: 575469406
copybara-service bot pushed a commit that referenced this pull request Nov 1, 2023
Fixes #4157

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4157 from PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment 73dc358
PiperOrigin-RevId: 578626660
copybara-service bot pushed a commit that referenced this pull request Nov 2, 2023
Fixes #4157

FUTURE_COPYBARA_INTEGRATE_REVIEW=#4157 from PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment 73dc358
PiperOrigin-RevId: 578626660
@copybara-service copybara-service bot closed this in bd43f40 Nov 2, 2023
@Stephan202 Stephan202 deleted the sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment branch December 23, 2023 09:16
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.

2 participants