Function redefinition fix

This PR fixes bugs when a function is redefined in a codeblock 
1. Redefine a function by changing its name
2. Redefine a function by changing its arguments
All statements using these modified functions must be re-executed.

http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-5179

@lukechurch  @ke-yu 
@monikaprabhu pls see the related LiveRunner test. 

Here is an example that original I used Linq but later I converted it to for-each:

My original code:

```
var deletedKeys = states.Keys.Where(k => states[k] == State.Deleted).ToList();
deletedKeys.Foreach(k => states.Remove(k));
states.Keys.ToList().ForEach(key => states[key] = State.Clean);
```

But this piece of code is totally *unreadable*. So changed it to for-each:

```
var newStates = new ...;
foreach (Guid guid in states.Keys)
{
    State state = states[guid];
    if (state != State.Deleted)
        newStates.Add(guid, State.Clean);
}
states = newStates;
```

We have some gigantic Linq expressions in code base, but I don't think they are good examples of using Linq :-)