Verbesserung, nun werden bei specialized Signaturen und Deskriptoren auch korrekt Generics berücksichtigt.

This commit is contained in:
Etienne Zink 2022-04-05 20:03:42 +02:00
parent 67df9aa262
commit cd5fbac987

View File

@ -84,7 +84,7 @@ public final class FunNGenerator implements FunNUtilities{
//generates a list of all params and substitutes the TPH
List<RefTypeOrTPHOrWildcardOrGeneric> parameters = Stream
.concat(argumentTypes.stream(), Stream.of(returnType))
.map(FunNGenerator::substituteTPH)
.map(this::substituteTPH)
.collect(Collectors.toList());
RefType superFunN = new RefType(new JavaClassName(getSuperClassName(argumentTypes.size())), parameters , null);
StringBuilder funNClassSignature = new StringBuilder(objectSignature + (superFunN.acceptTV(new TypeToSignature(false))));
@ -128,14 +128,14 @@ public final class FunNGenerator implements FunNUtilities{
public String getSpecializedDescriptor(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
Objects.requireNonNull(argumentTypes);
Objects.requireNonNull(returnType);
return applyDescriptor(new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)), null));
return applyDescriptor(getSpecializedFunNRefType(argumentTypes, returnType));
}
@Override
public String getSpecializedSignature(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType) {
Objects.requireNonNull(argumentTypes);
Objects.requireNonNull(returnType);
return applySignature(new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)), null));
return applySignature(getSpecializedFunNRefType(argumentTypes, returnType));
}
@Override
@ -163,11 +163,17 @@ public final class FunNGenerator implements FunNUtilities{
*/
private String applyNameDescriptor(RefTypeOrTPHOrWildcardOrGeneric a){ return a instanceof TypePlaceholder ? "LTPH;" : String.format("L%s;", applyDescriptor(a)); }
private static RefTypeOrTPHOrWildcardOrGeneric substituteTPH(RefTypeOrTPHOrWildcardOrGeneric t) {
private RefTypeOrTPHOrWildcardOrGeneric substituteTPH(RefTypeOrTPHOrWildcardOrGeneric t) {
if (t instanceof TypePlaceholder) {
TypePlaceholder tph = (TypePlaceholder) t;
return new GenericRefType(tph.getName()+"$", t.getOffset());
}
return t;
}
private RefType getSpecializedFunNRefType(List<RefTypeOrTPHOrWildcardOrGeneric> argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType){
return new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)),
Stream
.concat(argumentTypes.stream(), Stream.of(returnType))
.collect(Collectors.toList()),null);
}
}