Make ExpressionVisitor::visitCall() clearer.

Authored by flherne on Nov 27 2016, 11:26 PM.



Rename checkForDecorators() to docstringTypeOverride(), because it doesn't do anything involving decorators. (!)

Move the code choosing between class and function types to visitCall(), because it's nothing to do with docstring contents and made the different code paths very hard to follow.

Make it return the type it produces, rather than calling encounter() itself, for clarity.

Use the new isAlias argument of functionForCalled instead of some code to do the same thing.

Test Plan

No intended changes in behaviour.

Passes all existing tests.

TODO: There's one problem that remains unchanged - if we lose the alias state of class objects (e.g. by putting them in a container), they're interpreted and called as instances (i.e. we use __call__ instead of the constructor).
Add a test for this.

Diff Detail

R53 KDevelop: Python Support
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
flherne updated this revision to Diff 8558.Nov 27 2016, 11:26 PM
flherne retitled this revision from to Make ExpressionVisitor::visitCall() clearer..
flherne updated this object.
flherne edited the test plan for this revision. (Show Details)
flherne added a reviewer: brauch.
flherne set the repository for this revision to R53 KDevelop: Python Support.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptNov 27 2016, 11:26 PM
flherne updated this revision to Diff 8569.Nov 28 2016, 2:09 PM

Add an XFAIL test for constructors where we've lost the aliasing state (e.g. from containers). Broken with or without this patch.

Add a test for call when we don't have a declaration. Worked before, broken in the original version of this patch but wasn't tested.
Fixed that, messily. Looking for a tidier solution.

flherne updated this revision to Diff 8582.Nov 29 2016, 12:53 AM

Tidier than the last version.

brauch accepted this revision.Nov 30 2016, 11:10 PM
brauch edited edge metadata.

I don't see anything wrong, which doesn't mean nothing broke ;)
Anyways, I think if the tests still pass, breakage is unlikely at this place. Let's go for it, and watch closely for reports on 5.1.0 which might be related to this. Thank you!

This revision is now accepted and ready to land.Nov 30 2016, 11:10 PM
This revision was automatically updated to reflect the committed changes.