-
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
[PyROOT] Improve priority assignment of classes in same inheritance tree #9092
Conversation
|
Starting build on |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Build failed on ROOT-performance-centos8-multicore/default. Failing tests: |
|
Build failed on mac11.0/cxx17. Failing tests: |
|
Starting build on |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Build failed on ROOT-performance-centos8-multicore/default. Failing tests: |
|
Build failed on mac11.0/cxx17. Failing tests: |
|
Starting build on |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
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]>
2347a71 to
d310e90
Compare
|
Starting build on |
|
Build failed on ROOT-debian10-i386/cxx14. Errors:
|
|
Build failed on mac11.0/cxx17. Failing tests: |
etejedor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good thanks!
Fixes #8817