Ticket #5125: Avoid infinite recursion for recursive class definitions

Hi,

This simple fix makes sure that we don't go into infinite recursion when looking for symbols in recursive class definitions. Thanks to consider merging.

Best regards,
  Simon