close
Skip to content

UnnecessaryBoxedAssignment: avoid CCE on method reference#4157

Closed
Stephan202 wants to merge 1 commit into
google:masterfrom
PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment
Closed

UnnecessaryBoxedAssignment: avoid CCE on method reference#4157
Stephan202 wants to merge 1 commit into
google:masterfrom
PicnicSupermarket:sschroevers/avoid-CCE-in-UnnecessaryBoxedAssignment

Conversation

@Stephan202
Copy link
Copy Markdown
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
Copy Markdown
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.

}

void negative_methodReference() {
Function<String, Boolean> toBoolean = Boolean::valueOf;
Copy link
Copy Markdown
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