Skip to content

Commit

Permalink
[WIP] fix ExternalAnnotations18Test.testAnnotateMethodTypeParameter2
Browse files Browse the repository at this point in the history
Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 committed Apr 19, 2024
1 parent b1447fd commit 62fa919
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ static void getKey(StringBuilder builder, MethodSymbol methodSymbol, JavacBindin
ownerSymbol = ownerSymbol.owner;
}
if (ownerSymbol instanceof TypeSymbol ownerTypeSymbol) {
ITypeBinding ownerTypeBinding = new JavacTypeBinding(ownerTypeSymbol, resolver, null);
builder.append(ownerTypeBinding.getKey());
JavacTypeBinding.getKey(builder, ownerTypeSymbol.type, false, true);
} else {
throw new IllegalArgumentException("Method has no owning class");
}
Expand All @@ -146,7 +145,7 @@ static void getKey(StringBuilder builder, MethodSymbol methodSymbol, JavacBindin
if (!methodSymbol.getTypeParameters().isEmpty()) {
builder.append('<');
for (var typeParam : methodSymbol.getTypeParameters()) {
JavacTypeVariableBinding typeVarBinding = new JavacTypeVariableBinding(typeParam, resolver);
JavacTypeVariableBinding typeVarBinding = new JavacTypeVariableBinding(typeParam);
builder.append(typeVarBinding.getKey());
}
builder.append('>');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public String getKey() {
return builder.toString();
}

static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf) {
static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf, boolean erased) {
if (typeToBuild instanceof ArrayType arrayType) {
builder.append('[');
getKey(builder, arrayType.elemtype, isLeaf);
Expand All @@ -141,7 +141,7 @@ static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf) {
}
}
builder.append(typeToBuild.asElement().getQualifiedName().toString().replace('.', '/'));
if (typeToBuild.isParameterized()) {
if (typeToBuild.isParameterized() && !erased) {
builder.append('<');
for (var typeArgument : typeToBuild.getTypeArguments()) {
getKey(builder, typeArgument, false);
Expand All @@ -156,6 +156,10 @@ static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf) {
throw new UnsupportedOperationException("Unimplemented method 'getKey'");
}

static void getKey(StringBuilder builder, Type typeToBuild, boolean isLeaf) {
getKey(builder, typeToBuild, isLeaf, false);
}

@Override
public boolean isEqualTo(final IBinding binding) {
return binding instanceof final JavacTypeBinding other && //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.eclipse.jdt.internal.javac.dom;

import org.eclipse.jdt.core.dom.JavacBindingResolver;

import com.sun.tools.javac.code.Symbol.TypeVariableSymbol;

/**
Expand All @@ -10,20 +8,22 @@
*/
class JavacTypeVariableBinding {
private TypeVariableSymbol typeVar;
private JavacBindingResolver resolver;

JavacTypeVariableBinding(TypeVariableSymbol typeVar, JavacBindingResolver resolver) {
JavacTypeVariableBinding(TypeVariableSymbol typeVar) {
this.typeVar = typeVar;
this.resolver = resolver;
}

public String getKey() {
StringBuilder builder = new StringBuilder();
builder.append(typeVar.getSimpleName());
builder.append(':');
boolean prependColon = typeVar.getBounds().size() > 1
|| (typeVar.getBounds().size() > 0 && typeVar.getBounds().get(0).isInterface());
for (var bound : typeVar.getBounds()) {
JavacTypeBinding boundTypeBinding = new JavacTypeBinding(bound.tsym, this.resolver, null);
builder.append(boundTypeBinding.getKey());
if (prependColon) {
builder.append(":");
}
JavacTypeBinding.getKey(builder, bound, false);
}
return builder.toString();
}
Expand Down

0 comments on commit 62fa919

Please sign in to comment.