title: Treating a forced downcast as optional will never produce 'nil'
body: <p>I've been playing around with Swift and discovered that when down casting an object to be inserted into a dictionary, I get a weird warning: <code>Treating a forced downcast to 'String' as optional will never produce 'nil'</code>. If I replace <code>as</code> with <code>as?</code> then the warning goes away.</p>
  
  <pre><code>func test() -&gt; AnyObject! {
    return "Hi!"
  }
  
  var dict = Dictionary&lt;String,String&gt;()
  dict["test"]=test() as String
  </code></pre>
  
  <p>Apple's documentation says the following</p>
  
  <blockquote>
    <p>Because downcasting can fail, the type cast operator comes in two different forms. The optional form, <code>as?</code>, returns an optional value of the type you are trying to downcast to. The forced form, <code>as</code>, attempts the downcast and force-unwraps the result as a single compound action.</p>
  </blockquote>
  
  <p>I'm unclear as to why using <code>as?</code> instead of <code>as</code> is correct here. Some testing reveals that if I change test() to return an Int instead of a String, the code will quit with an error if I continue using <code>as</code>. If I switch to using <code>as?</code> then the code will continue execution normally and skip that statement (dict will remain empty). However, I'm not sure why this is preferable. In my opinion, I would rather the program quit with an error and let me know that the cast was unsuccessful then simply ignore the erroneous statement and keep executing.</p>
  
  <p>According to the documentation, I should use the forced form "only when you are sure that the downcast will always succeed." In this case I am sure that the downcast will always succeed since I know <code>test()</code> can only return a String so I would assume this is a perfect situation for the forced form of down casting. So why is the compiler giving me a warning?</p>