Fixed Bug 152 Faculty Probleme

This commit is contained in:
Fayez Abu Alia 2019-06-07 10:28:48 +02:00
parent b801e144c3
commit 857d63322e
2 changed files with 19 additions and 8 deletions

View File

@ -896,7 +896,8 @@ public class BytecodeGenMethod implements StatementVisitor {
// methodCall.arglist.accept(this);
// is methodCall.receiver functional Interface)?
if (varsFunInterface.contains(methodCall.receiver.getType()) || (methodRefl!= null && receiverRefl.contains("interface"))) {
if (varsFunInterface.contains(methodCall.receiver.getType()) || (methodRefl!= null && receiverRefl.contains("interface")) ||
receiverName.contains("$$")) {
mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, clazz.replace(".", "/"), methodCall.name,
mDesc, true);
} else {
@ -908,16 +909,12 @@ public class BytecodeGenMethod implements StatementVisitor {
if(methodRefl != null && !methodRefl.getReturnType().isPrimitive()) {
if(methodRefl.getReturnType().equals(Object.class)) {
String checkCast = getResolvedType(methodCall.getType());
if(!checkCast.contains("TPH ")) {
int pos = checkCast.length();
if(checkCast.contains("<"))
pos = checkCast.indexOf("<");
mv.visitTypeInsn(Opcodes.CHECKCAST,checkCast.substring(0,pos));
}
helper.createCheckCast(methodCall,mv);
}
if(isBinaryExp)
doUnboxing(getResolvedType(methodCall.getType()));
} else if(receiverName.contains("$$") && !methCallType.equals(Type.getInternalName(Object.class))) {
helper.createCheckCast(methodCall,mv);
}
System.out.println("ISParent Binary = "+isParentBinary +" -> " + parentBinary);
if(methodRefl == null && (parentBinary || !isReturnStmt)) {
@ -926,6 +923,7 @@ public class BytecodeGenMethod implements StatementVisitor {
}
}
private String getDescForMethInCurrPkg(String name) {
// TODO Auto-generated method stub

View File

@ -282,5 +282,18 @@ public class MethodCallHelper {
}
}
/**
* @param methodCall
*/
public void createCheckCast(MethodCall methodCall, MethodVisitor mv) {
String checkCast = getResolvedType(methodCall.getType());
if(!checkCast.contains("TPH ")) {
int pos = checkCast.length();
if(checkCast.contains("<"))
pos = checkCast.indexOf("<");
mv.visitTypeInsn(Opcodes.CHECKCAST,checkCast.substring(0,pos));
}
}
}