Fix codegen a bit, and add missing constraints

This commit is contained in:
Vic Nightfall 2023-02-10 14:54:44 +01:00
parent 239698c8d6
commit 29f654279b
2 changed files with 8 additions and 3 deletions

View File

@ -949,7 +949,7 @@ public class Codegen {
mv.visitMethodInsn(call.isInterface() ? INVOKEINTERFACE : call.isStatic() ? INVOKESTATIC: call.name().equals("<init>") ? INVOKESPECIAL : INVOKEVIRTUAL,
call.owner().getInternalName(), call.name(), descriptor, call.isInterface());
if (call.returnType() != null && !(call.returnType() instanceof TargetPrimitiveType)) {
if (call.type() != null && call.returnType() != null && !(call.returnType() instanceof TargetPrimitiveType)) {
if (!call.returnType().equals(call.type()) && !(call.type() instanceof TargetGenericType))
mv.visitTypeInsn(CHECKCAST, call.type().getInternalName());
unboxPrimitive(state, call.type());

View File

@ -575,16 +575,22 @@ public class ASTToTargetAST {
private void findChain(Set<TypePlaceholder> referenced, Set<ResultPair<?, ?>> input, Set<ResultPair<?, ?>> output, TypePlaceholder start, TypePlaceholder end, Set<TypePlaceholder> chain) {
if (referenced.contains(end)) {
var pair = new PairTPHsmallerTPH(start, end);
if (input.contains(pair)) output.add(pair);
output.add(pair);
return;
}
var foundNext = false;
for (var pair : input) {
if (pair instanceof PairTPHsmallerTPH ptph && ptph.left.equals(end)) {
if (chain.contains(ptph.right)) return;
chain = new HashSet<>(chain);
chain.add(ptph.right);
findChain(referenced, input, output, start, ptph.right, chain);
foundNext = true;
}
}
if (!foundNext) {
output.add(new PairTPHequalRefTypeOrWildcardType(start, OBJECT));
}
}
void eliminateInnerTypeVariables(Set<TypePlaceholder> referenced, Set<ResultPair<?, ?>> input) {
@ -594,7 +600,6 @@ public class ASTToTargetAST {
if (pair instanceof PairTPHsmallerTPH pthp && pthp.left.equals(tph)) {
var chain = new HashSet<TypePlaceholder>();
chain.add(tph);
chain.add(pthp.right);
findChain(referenced, input, output, tph, pthp.right, chain);
}
}