Fix the condition for qualifying the symbol of methods and functions in the enclosing declaration

Fixes #604