Skip to content

Commit

Permalink
Use getMethodDescriptorByName when creating unboxing method calls
Browse files Browse the repository at this point in the history
It's important that we resolve the method on the specific we're unboxing as we may immediately devirtualize the call. If we incorrectly resolve to the parent method we'll improperly devirtualize it.

PiperOrigin-RevId: 724499510
  • Loading branch information
kevinoconnor7 authored and copybara-github committed Feb 8, 2025
1 parent ab5125b commit 359eae0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.j2cl.common.StringUtils.capitalize;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
Expand Down Expand Up @@ -689,7 +690,9 @@ public static MethodCall createUnboxingMethodCall(
Expression expression, DeclaredTypeDescriptor boxedType) {

MethodDescriptor valueMethodDescriptor =
boxedType.getMethodDescriptor(boxedType.toUnboxedType().getSimpleSourceName() + "Value");
boxedType.getMethodDescriptorByName(
boxedType.toUnboxedType().getSimpleSourceName() + "Value");
checkState(valueMethodDescriptor.getEnclosingTypeDescriptor().isSameBaseType(boxedType));

return MethodCall.Builder.from(valueMethodDescriptor).setQualifier(expression).build();
}
Expand Down

0 comments on commit 359eae0

Please sign in to comment.