Make `@deprecated` decorator work for classes.

As mentioned in #2051.