title: Type does not conform to protocol
body: <p>I'm still having trouble understanding some subtleties of generics in Swift. I define the following types:</p>
  
  <pre><code>protocol SomeProtocol {
      func setValue(value: Int)
  }
  
  class ProtocolLabel : UILabel, SomeProtocol {
      func setValue(value: Int) {
  
      }
  }
  
  class ProtocolImageView : UIImageView, SomeProtocol {
      func setValue(value: Int) {
      }
  }
  </code></pre>
  
  <p>viewForValue(2)
  Now I defined the following function. I expect <strong>T to be a UIView that conforms to protocol SomeProtocol</strong>.</p>
  
  <pre><code>func viewForValue&lt;T where T: SomeProtocol, T: UIView&gt;(param: Int) -&gt; UIView {
      var someView: T
      if param &gt; 0 {
          someView = ProtocolLabel() as T
      } else {
          someView = ProtocolImageView() as T
      }
      someView.setValue(2)
      someView.frame = CGRectZero
      return someView
  }
  </code></pre>
  
  <p>However, I'm getting the following compile error when I execute the code:</p>
  
  <pre><code>viewForValue(2) // &lt;-- Type 'UIView' does not conform to protocol 'SomeProtocol'
  </code></pre>
  
  <p>It seems that in the where clause I can't specify a class that does not implement the protocol. Why is that?</p>
  
  <p>Thanks in advance.</p>