%implicitconv is improved for overloaded functions.
Like in C++, the methods with the actual types are considered before trying implicit conversions.
This commit is contained in:
parent
1cc735df5e
commit
b58dabced9
4 changed files with 117 additions and 5 deletions
|
|
@ -84,3 +84,33 @@
|
|||
int get_AA_val(AA a) { return a.ii; }
|
||||
int get_AA_ref(const AA& a) { return a.ii; }
|
||||
}
|
||||
|
||||
|
||||
/****************** Overloading priority *********************/
|
||||
|
||||
%inline %{
|
||||
class BBB {
|
||||
public:
|
||||
BBB(const B &) {}
|
||||
};
|
||||
|
||||
class CCC {
|
||||
public:
|
||||
CCC(const BBB &) : checkvalue(0) {}
|
||||
int xx(int i) { return 11; }
|
||||
int xx(const A& i) { return 22; }
|
||||
int yy(int i, int j) { return 111; }
|
||||
int yy(const A& i, const A& j) { return 222; }
|
||||
int checkvalue;
|
||||
};
|
||||
%}
|
||||
|
||||
// CCC(const BBB &) was being called instead of this constructor (independent of being added via %extend)
|
||||
%extend CCC {
|
||||
CCC(const B& b) {
|
||||
CCC* ccc = new CCC(b);
|
||||
ccc->checkvalue = 10;
|
||||
return ccc;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -114,3 +114,12 @@ try:
|
|||
raise RuntimeError
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
### overloading priority test ###
|
||||
|
||||
ccc = CCC(B())
|
||||
check(ccc.checkvalue, 10)
|
||||
check(ccc.xx(123), 11)
|
||||
check(ccc.yy(123, 123), 111)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue