Merge pull request #235 from dontpanic92/master

Go: fix overload functions with polymorphic
This commit is contained in:
ianlancetaylor 2014-11-17 08:28:07 -08:00
commit da7133aa8e
4 changed files with 35 additions and 1 deletions

View file

@ -310,6 +310,7 @@ CPP_TEST_CASES += \
overload_extend \
overload_method \
overload_numeric \
overload_polymorphic \
overload_rename \
overload_return_type \
overload_simple \

View file

@ -0,0 +1,11 @@
package main
import "./overload_polymorphic"
func main(){
t := overload_polymorphic.NewDerived()
if overload_polymorphic.Test(t) != 0 {
panic("failed")
}
}

View file

@ -0,0 +1,22 @@
%module overload_polymorphic
%inline %{
class Base {
public:
Base(){}
virtual ~Base(){}
};
class Derived : public Base {
public:
Derived(){}
virtual ~Derived(){}
};
int test(Base* base){ return 0;}
int test(int hello){ return 1; }
%}

View file

@ -4414,7 +4414,7 @@ private:
}
fn = i + 1;
Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, tm);
Printf(f_go_wrappers, "\t\tif _, ok := a[%d].(%s); !ok {\n", j, goType(pj, Getattr(pj, "type")));
Printf(f_go_wrappers, "\t\t\tgoto check_%d\n", fn);
Printv(f_go_wrappers, "\t\t}\n", NULL);
}