diff --git a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java index e5bce5f4..411d9bf2 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/FunNGenerator.java @@ -28,12 +28,15 @@ public class FunNGenerator { private static final String objectSuperType = Type.getInternalName(Object.class).replace('.','/'); private static final String objectSignature = applySignature(TargetType.Object); + private static final String VOID = "Ljava/lang/Void;"; + public static class GenericParameters { int start; public List parameters = new ArrayList<>(); } private static String applyDescriptor(TargetType type, GenericParameters gep) { + if (type == null) return VOID; var res = "L" + type.getInternalName(); if (type instanceof TargetSpecializedType a) { if (a.params().size() > 0) { @@ -62,6 +65,7 @@ public class FunNGenerator { private static String applyNameDescriptor(TargetType a){ return a instanceof TargetGenericType ? "LTPH;" : String.format("%s", applySignature(a)); } public static String encodeType(TargetType type) { + if (type == null) return VOID; return applyNameDescriptor(type).replace("/", "$").replace(";", "$_$"); } diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index cb982fa0..85feca0d 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -398,8 +398,7 @@ public class ASTToTargetAST { static TargetType flattenFunNType(List params, FunNGenerator.GenericParameters gep) { var newParams = new ArrayList(); - for (var i = 0; i < params.size(); i++) { - var param = params.get(i); + for (TargetType param : params) { if (param instanceof TargetSpecializedType fn) { collectArguments(fn, newParams); } else { @@ -422,7 +421,12 @@ public class ASTToTargetAST { if (name.equals("void")) return null; - var params = refType.getParaList().stream().map(type -> convert(type, generics)).toList(); + var params = refType.getParaList().stream().map(type -> { + var res = convert(type, generics); + if (res == null) res = new TargetRefType("java.lang.Void"); + return res; + }).toList(); + if (name.matches("Fun\\d+\\$\\$")) { // TODO This seems like a bad idea var className = FunNGenerator.getSpecializedClassName(FunNGenerator.getArguments(params), FunNGenerator.getReturnType(params)); if (!usedFunNSuperTypes.contains(params.size())) {