Covariant return type fixes...

Fixed error where the base class was being used to wrap the derived class C++ pointer.
Emit a warning when encountering these return types as the return type is changed to the base class type.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5590 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2003-12-23 21:46:56 +00:00
commit cf3a5e6222

View file

@ -1226,7 +1226,7 @@ class CSHARP : public Language {
* ----------------------------------------------------------------------------- */
void proxyClassFunctionHandler(Node *n) {
SwigType *t = Getattr(n,"virtual:type") ? Getattr(n,"virtual:type") : Getattr(n,"type");
SwigType *t = Getattr(n,"type");
ParmList *l = Getattr(n,"parms");
String *intermediary_function_name = Getattr(n,"imfuncname");
String *proxy_function_name = Getattr(n,"proxyfuncname");
@ -1253,8 +1253,13 @@ class CSHARP : public Language {
/* Get return types */
if ((tm = Swig_typemap_lookup_new("cstype",n,"",0))) {
substituteClassname(t, tm);
// Note that in the case of polymorphic (covariant) return types, the method's return type is changed to be the base of the C++ return type
SwigType *virtualtype = Getattr(n,"virtual:type");
substituteClassname(virtualtype ? virtualtype : t, tm);
Printf(return_type, "%s", tm);
if (virtualtype)
Swig_warning(WARN_CSHARP_COVARIANT_RET, input_file, line_number,
"Covariant return types not supported in C#. Proxy method will return %s.\n", SwigType_str(virtualtype,0));
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number,
"No cstype typemap defined for %s\n", SwigType_str(t,0));