throw new WeaselCompilerException(instructionList.getLine(), "Types %s and %s are not compatible", returnType, weaselGenericClass);
}
}
return instructionList;
}
WeaselGenericClass returnWrapper;
WeaselGenericClass expectWrapper;
if(returnType.getBaseClass().isPrimitive()){
returnWrapper = new WeaselGenericClass(compiler.getWeaselClass(WeaselPrimitive.getWrapper(returnType.getBaseClass())));
}else{
returnWrapper = returnType;
}
if(weaselGenericClass.getBaseClass().isPrimitive()){
expectWrapper = new WeaselGenericClass(compiler.getWeaselClass(WeaselPrimitive.getWrapper(weaselGenericClass.getBaseClass())));
}else{
expectWrapper = weaselGenericClass;
}
if(returnType.getBaseClass().isPrimitive()){
instructionList.addWithoutLine(new WeaselInstructionCast(returnWrapper.getBaseClass().getByteName()));
}
if(!returnWrapper.getBaseClass().isInterface() && !expectWrapper.getBaseClass().isInterface()){
if(returnWrapper.canCastTo(expectWrapper) && !expectWrapper.canCastTo(returnWrapper)){
throw new WeaselCompilerException(instructionList.getLine(), "Types %s and %s are not compatible", returnType, weaselGenericClass);
}
}
instructionList.addWithoutLine(new WeaselInstructionCast(expectWrapper.getBaseClass().getRealName()));
if(weaselGenericClass.getBaseClass().isPrimitive()){
instructionList.addWithoutLine(new WeaselInstructionCastPrimitive(WeaselPrimitive.getPrimitiveID(weaselGenericClass.getBaseClass())));
}
returnType = weaselGenericClass;