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

View File

@ -283,4 +283,17 @@ 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));
}
}
} }