[Go] Fix overloading on an undefined type.
This commit is contained in:
parent
b15a66f2ab
commit
a6a9a89524
3 changed files with 45 additions and 2 deletions
|
|
@ -6,6 +6,10 @@ func main(){
|
||||||
t := overload_polymorphic.NewDerived()
|
t := overload_polymorphic.NewDerived()
|
||||||
|
|
||||||
if overload_polymorphic.Test(t) != 0 {
|
if overload_polymorphic.Test(t) != 0 {
|
||||||
panic("failed")
|
panic("failed 1")
|
||||||
|
}
|
||||||
|
|
||||||
|
if overload_polymorphic.Test2(t) != 1 {
|
||||||
|
panic("failed 2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,4 +19,8 @@ public:
|
||||||
int test(Base* base){ return 0;}
|
int test(Base* base){ return 0;}
|
||||||
int test(int hello){ return 1; }
|
int test(int hello){ return 1; }
|
||||||
|
|
||||||
|
class Unknown;
|
||||||
|
int test2(Unknown* unknown) { return 0; }
|
||||||
|
int test2(Base* base) { return 1; }
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -5652,8 +5652,43 @@ private:
|
||||||
++num_braces;
|
++num_braces;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Delete(tm);
|
||||||
|
|
||||||
|
tm = goType(pj, Getattr(pj, "type"));
|
||||||
|
|
||||||
|
// Now for a C++ class, tm is the interface type. If this
|
||||||
|
// is based on an undefined type, then require matching on
|
||||||
|
// the underlying integer type. This is because the
|
||||||
|
// interface type we generate for an undefined type will
|
||||||
|
// match the interface generated for any C++ class type.
|
||||||
|
// It has to work that way so that we can handle a derived
|
||||||
|
// type of an ignored type. It's unlikely that anybody
|
||||||
|
// will have a value of an undefined type, but we support
|
||||||
|
// it because it worked in the past.
|
||||||
|
SwigType *ty = SwigType_typedef_resolve_all(Getattr(pj, "type"));
|
||||||
|
while (true) {
|
||||||
|
if (SwigType_ispointer(ty)) {
|
||||||
|
SwigType_del_pointer(ty);
|
||||||
|
} else if (SwigType_isarray(ty)) {
|
||||||
|
SwigType_del_array(ty);
|
||||||
|
} else if (SwigType_isreference(ty)) {
|
||||||
|
SwigType_del_reference(ty);
|
||||||
|
} else if (SwigType_isqualifier(ty)) {
|
||||||
|
SwigType_del_qualifier(ty);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Getattr(undefined_types, ty) && !Getattr(defined_types, ty)) {
|
||||||
|
Delete(tm);
|
||||||
|
tm = goWrapperType(pj, Getattr(pj, "type"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Delete(ty);
|
||||||
|
|
||||||
fn = i + 1;
|
fn = i + 1;
|
||||||
Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, goType(pj, Getattr(pj, "type")));
|
Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, tm);
|
||||||
Printf(f_go_wrappers, "\t\t\tgoto check_%d\n", fn);
|
Printf(f_go_wrappers, "\t\t\tgoto check_%d\n", fn);
|
||||||
Printv(f_go_wrappers, "\t\t}\n", NULL);
|
Printv(f_go_wrappers, "\t\t}\n", NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue