From cd5fbac9875ac356f9565a4092363fc5731bbab0 Mon Sep 17 00:00:00 2001 From: Etienne Zink Date: Tue, 5 Apr 2022 20:03:42 +0200 Subject: [PATCH] =?UTF-8?q?Verbesserung,=20nun=20werden=20bei=20specialize?= =?UTF-8?q?d=20Signaturen=20und=20Deskriptoren=20auch=20korrekt=20Generics?= =?UTF-8?q?=20ber=C3=BCcksichtigt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dhbwstuttgart/bytecode/funN/FunNGenerator.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java index 6fb10244..83ed622d 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/funN/FunNGenerator.java @@ -84,7 +84,7 @@ public final class FunNGenerator implements FunNUtilities{ //generates a list of all params and substitutes the TPH List 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 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 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 argumentTypes, RefTypeOrTPHOrWildcardOrGeneric returnType){ + return new RefType(new JavaClassName(getSpecializedClassName(argumentTypes, returnType)), + Stream + .concat(argumentTypes.stream(), Stream.of(returnType)) + .collect(Collectors.toList()),null); + } }