-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[PyROOT] Improve priority assignment of classes in same inheritance tree #9092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vepadulano
merged 1 commit into
root-project:master
from
vepadulano:cppyy-inheritance-priority
Oct 12, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[PyROOT] Improve priority assignment of classes in same inheritance tree
The current implementation of the CPPMethod::GetPriority function considers only direct bases of the class type given as input parameter to a certain function.
This can lead to situations which are easily distinguishable but that lead to the same overload being called when passing instances of different classes of the same inheritance tree.
For example,
```python
import ROOT
ROOT.gInterpreter.Declare(
'''
class A {};
class B: public A {};
class C: public B {};
void myfunc(const B &b){
std::cout << "B" << std::endl;
}
void myfunc(const C &c){
std::cout << "C" << std::endl;
}
''')
ROOT.myfunc(ROOT.B())
ROOT.myfunc(ROOT.C())
```
Prints `B` for both function calls. This commit introduces a new function in cppyy that retrieves the number of bases in the longest branch of the inheritance tree for a certain class. This helps better distinguish cases like the one above, that are now solved.
The new logic still does not solve another issue, namely the fact that in certain situations which would throw errors in C++ due to their ambiguity, cppyy resorts to calling the function overload with the highest priority. A couple of tests have been added in roottest to show both behaviours.
Co-authored-by: Enric Tejedor Saavedra <[email protected]>- Loading branch information
commit d310e90cc91fca1ec4103fbc03389260a2704e6e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.