fix Checker.iterVisibleScopes + simplify code

Checker.iterVisibleScopes properly handles generator scopes.