Improve support for 'with' statements.
ClosedPublic

Authored by flherne on Oct 9 2018, 5:36 PM.

Details

Summary

The previous code didn't look at __enter__(), and assumed that all context-managers returned their own type.

We also didn't account for targets other than simple names, e.g. with Mgr() as (foo, bar):

Thanks to Nicolás Alvarez.

Test Plan

Seems to work. I'll add some duchaintests before pushing.

Diff Detail

Repository
R53 KDevelop: Python Support
Lint
Lint Skipped
Unit
Unit Tests Skipped
flherne created this revision.Oct 9 2018, 5:36 PM
Restricted Application added a project: KDevelop. · View Herald TranscriptOct 9 2018, 5:36 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald Transcript
flherne requested review of this revision.Oct 9 2018, 5:36 PM
brauch accepted this revision.Oct 9 2018, 6:09 PM

Otherwise looks good! If you feel super ambitious you could add a test, should be very simple ;)

duchain/declarationbuilder.cpp
376

Please check whether the type assigned to this function is indeed a FunctionType, yes it should be, but it happens sometimes that other code screws this up and then this will crash

This revision is now accepted and ready to land.Oct 9 2018, 6:09 PM
This revision was automatically updated to reflect the committed changes.