forked from JavaTX/JavaCompilerCore
Allow Void as return type for Lambdas
This commit is contained in:
parent
c51190feef
commit
1be27746e3
@ -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<TargetType> 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(";", "$_$");
|
||||
}
|
||||
|
||||
|
@ -398,8 +398,7 @@ public class ASTToTargetAST {
|
||||
|
||||
static TargetType flattenFunNType(List<TargetType> params, FunNGenerator.GenericParameters gep) {
|
||||
var newParams = new ArrayList<TargetType>();
|
||||
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())) {
|
||||
|
Loading…
Reference in New Issue
Block a user