Skip to content

Commit

Permalink
[javac] Use the correct enclosing type in the creation of method desc…
Browse files Browse the repository at this point in the history
…riptors.

PiperOrigin-RevId: 700125844
  • Loading branch information
rluble authored and copybara-github committed Nov 25, 2024
1 parent 09a44b2 commit 794e55d
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,19 @@ MethodDescriptor createMethodDescriptor(
DeclaredTypeDescriptor enclosingTypeDescriptor =
createDeclaredTypeDescriptor(declarationMethodElement.getEnclosingElement().asType());

// TODO(b/380911302): Remove redundance in the creation of method descriptors.
// The enclosing type descriptor might be a subclass of the actual type descriptor, hence
// traverse the supertypes to find the actual enclosing type descriptor without loosing the
// parameterization.
DeclaredTypeDescriptor unparameterizedEnclosingTypeDescriptor =
createDeclaredTypeDescriptor(
((MethodSymbol) declarationMethodElement).baseSymbol().getEnclosingElement().asType());
enclosingTypeDescriptor =
enclosingTypeDescriptor.getAllSuperTypesIncludingSelf().stream()
.filter(unparameterizedEnclosingTypeDescriptor::isSameBaseType)
.findFirst()
.get();

MethodDescriptor declarationMethodDescriptor = null;
List<? extends TypeMirror> parameterTypes = methodType.getParameterTypes();
if (isSpecialized(
Expand Down

0 comments on commit 794e55d

Please sign in to comment.