Don't emit __extends if one is already in scope

Addresses #1350 and probably some other suggestions as well.

This changes the "do we need to emit __extends" logic to see if a symbol named `__extends` is already in visible scope at the site of the class declaration.
please break this into multiple lines.  Or provide a helper function for it.