[swift-evolution] Pitch: Deprecate/remove AnyObject method dispatch

Slava Pestov spestov at apple.com
Tue Oct 24 17:01:32 CDT 2017

Hi all,

Dynamic dispatch of methods through AnyObject is a source of implementation complexity, has many known bugs which we are not going to fix, and no longer makes sense now in an id-as-Any world; AnyObject is not the ‘common currency’ type for arbitrary Objective-C objects anymore.

I would like to propose we deprecate it as follows:

- Unconditional warning in Swift 4.1, with a fixit to add an ‘as’ cast to cast the base value to the right type
- Error in Swift 5 in -swift-version 5 mode

Thoughts? Does anyone actually rely on this feature, instead of just stumbling on it by accident once in a while?


More information about the swift-evolution mailing list