Skip to content

Commit

Permalink
simplified appendConstructedTypeName
Browse files Browse the repository at this point in the history
use getNamedType instead of manually retrieving the last element of
supertypes
  • Loading branch information
LorenzoBettini committed Jan 2, 2024
1 parent 30c2d66 commit 481fbb7
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@

import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.Inject;

Expand Down Expand Up @@ -1133,12 +1132,12 @@ protected void constructorCallToJavaExpression(final XConstructorCall expr, ITre

protected void appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) {
JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType();
IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall);
LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall);
if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) {
typeAppendable.append(Iterables.getLast(type.getSuperTypes()).getType());
typeAppendable.append(actualType.getNamedType().getRawTypeReference());
} else {
IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(constructorCall);
LightweightTypeReference actualType = resolvedTypes.getActualType(constructorCall).getRawTypeReference();
typeAppendable.append(actualType);
typeAppendable.append(actualType.getRawTypeReference());
}
}

Expand Down

0 comments on commit 481fbb7

Please sign in to comment.