diff --git a/Examples/test-suite/doxygen_misc_constructs.i b/Examples/test-suite/doxygen_misc_constructs.i
index c95e85683..c1b3eea31 100644
--- a/Examples/test-suite/doxygen_misc_constructs.i
+++ b/Examples/test-suite/doxygen_misc_constructs.i
@@ -104,6 +104,9 @@
};
+ /// @return This is a bad place for this tag, but it should be ignored.
+ struct StructWithReturnComment {};
+
/**
An example of a list in a documentation comment.
diff --git a/Examples/test-suite/java/doxygen_misc_constructs_runme.java b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
index 6d018b9d2..5d95bd565 100644
--- a/Examples/test-suite/java/doxygen_misc_constructs_runme.java
+++ b/Examples/test-suite/java/doxygen_misc_constructs_runme.java
@@ -117,6 +117,9 @@ public class doxygen_misc_constructs_runme {
wantedComments.put("doxygen_misc_constructs.ClassWithNestedEnum.ENested.THREE",
" desc of three\n");
+ wantedComments.put("doxygen_misc_constructs.StructWithReturnComment",
+ " @return This is a bad place for this tag, but it should be ignored.");
+
wantedComments.put("doxygen_misc_constructs.doxygen_misc_constructs.showList()",
" An example of a list in a documentation comment.
\n" +
"
\n" +
diff --git a/Source/Doxygen/pydoc.cxx b/Source/Doxygen/pydoc.cxx
index 8c3090035..fc3b0ea09 100644
--- a/Source/Doxygen/pydoc.cxx
+++ b/Source/Doxygen/pydoc.cxx
@@ -336,8 +336,13 @@ static std::string getPyDocType(Node *n, const_String_or_char_ptr lname = "") {
std::string type;
String *s = Swig_typemap_lookup("doctype", n, lname, 0);
+ if (!s) {
+ if (String *t = Getattr(n, "type"))
+ s = SwigType_str(t, "");
+ }
+
if (!s)
- s = SwigType_str(Getattr(n, "type"), "");
+ return type;
if (Language::classLookup(s)) {
// In Python C++ namespaces are flattened, so remove all but last component