Fixes strange error messages for invalid generic method definitions

Closes PR 13681

Please merge to v5.3.4
Fix #:methods regression at top-level

Please merge to v5.3.4