Assignment localAssignment = new Assignment(localVariable, field);
InstanceOf checkType = new InstanceOf(localAssignment, JavaTypeNames.RTRESULT_FUNCTION);
MethodInvocation getValue = new MethodInvocation.Instance(localVariable, "getValue", JavaTypeNames.RTVALUE, MethodInvocation.InvocationType.VIRTUAL);
Assignment fieldAssignment = new Assignment(field, getValue);
ReturnStatement returnNewVal = new ReturnStatement(fieldAssignment);
IfThenElseStatement ifThen = new IfThenElseStatement(checkType, returnNewVal);
javaMethod.addStatement(ifThen);
javaMethod.addStatement(new ReturnStatement (localVariable));
} else {
// The field is strict and therefore already in WHNF.