Skip to content

Commit

Permalink
[javac] Fix issues with the construction of SuperReference and `Met…
Browse files Browse the repository at this point in the history
…hodReference`.

PiperOrigin-RevId: 694246812
  • Loading branch information
rluble authored and copybara-github committed Nov 7, 2024
1 parent af9a472 commit 9699a29
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,10 @@ private Expression convertMemberReference(JCMemberReference memberReference) {
environment.createMethodDescriptor(
(ExecutableType) memberReference.referentType, returnType, methodSymbol);
Expression qualifier = convertExpressionOrNull(memberReference.getQualifierExpression());
if (qualifier instanceof JavaScriptConstructorReference) {
// The qualifier was just the class name, remove it.
qualifier = null;
}

return MethodReference.newBuilder()
.setTypeDescriptor(expressionTypeDescriptor)
Expand Down Expand Up @@ -922,11 +926,21 @@ private Expression convertFieldAccess(JCFieldAccess fieldAccess) {
/* isQualified= */ true);
}
if (fieldAccess.name.contentEquals("super")) {
return new SuperReference(
DeclaredTypeDescriptor typeDescriptor =
environment
.createDeclarationForType((ClassSymbol) ((JCIdent) expression).sym)
.toDescriptor());
.toDescriptor();

boolean isQualified = !typeDescriptor.isInterface();
if (isQualified) {
// This is a qualified super call, targeting an outer class method.
return new SuperReference(typeDescriptor, isQualified);
}

// Call targeting a method in the super types, including superinterfaces.
return new SuperReference(getCurrentType().getTypeDescriptor());
}

Expression qualifier;
if (fieldAccess.sym instanceof VariableElement) {
qualifier = convertExpression(expression);
Expand Down

0 comments on commit 9699a29

Please sign in to comment.