<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">It's mainly to support heterogeneous dictionary literals. There's not usually a need to upcast to AnySequence regularly, since most things that <i class="">take</i>&nbsp;sequences should be using generics, but heterogeneity and generics don't play well together.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 19, 2016, at 9:00, Tim Vermeulen via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Any idea why Swift supports implicit casting to AnyHashable, but not to, say, AnySequence?<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Aug 18, 2016, at 9:54 AM, Adel Zhang via swift-users&lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt;wrote:<br class=""><br class="">Any other situation when implicit type casting works?<br class=""></blockquote>I don't know if there's a comprehensive list anywhere. Here are the ones I can think of:<br class=""><br class="">1. A subtype can be used where a supertype is expected; for instance, you can pass an `Int` to a parameter typed `Any` without a cast. The same is true of superclasses: `NSString` can be used where `NSObject` is expected. Obvious, but worth mentioning.<br class=""><br class="">2. Swift 3's `AnyHashable` isn't *really* a supertype of `Hashable` types, but it's sort of treated as one.<br class=""><br class="">3. The built-in `Array`, `Dictionary`, `Set`, and `Optional` types can be implicitly converted to the same data structure, but with supertypes of its generic parameters. For instance, an `Array&lt;Int&gt;` can be passed to a parameter of type `Array&lt;Any&gt;`. This is not a general feature of generics—it's special-cased for these types.<br class=""><br class="">4. As you noticed, a type can be implicitly made more `Optional`; that is, `Int` converts to `Optional&lt;Int&gt;`, `Optional&lt;Optional&lt;Int&gt;&gt;`, and so on.<br class=""><br class="">5. In Swift 2, importing Foundation activates many implicit conversions between Foundation and Standard Library types, including conversions to AnyObject. Many (perhaps all?) are gone in Swift 3. (However, Foundation still has plenty of magical `as` casts.)<br class=""><br class="">Hope this helps,<br class="">--<br class="">Brent Royal-Gordon<br class="">Architechies<br class=""><br class=""><br class=""><br class=""><br class=""></blockquote>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></div></blockquote></div><br class=""></body></html>