diff --git a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java index 70810cbd6..d32aa8513 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/Codegen.java @@ -949,7 +949,7 @@ public class Codegen { mv.visitMethodInsn(call.isInterface() ? INVOKEINTERFACE : call.isStatic() ? INVOKESTATIC: call.name().equals("") ? 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()); diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index fbe9ce756..d82d658d5 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -575,16 +575,22 @@ public class ASTToTargetAST { private void findChain(Set referenced, Set> input, Set> output, TypePlaceholder start, TypePlaceholder end, Set 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 referenced, Set> input) { @@ -594,7 +600,6 @@ public class ASTToTargetAST { if (pair instanceof PairTPHsmallerTPH pthp && pthp.left.equals(tph)) { var chain = new HashSet(); chain.add(tph); - chain.add(pthp.right); findChain(referenced, input, output, tph, pthp.right, chain); } }