title: Casting type conforming to multiple protocols as a single protocol
body: <p>I'm having trouble getting Swift to understand that an array of objects that conform to two protocols is the same as an array that conforms to one of them.</p>
  
  <p>Let's say I have two protocols, Identifiable and Namable:</p>
  
  <pre><code>protocol Identifiable {
      var identifier: Int { get }
  }
  
  protocol Namable {
      var name: String { get }
  }
  </code></pre>
  
  <p>And two functions that will print info about arrays of objects conforming to those protocols:</p>
  
  <pre><code>func printIdentifiers(itemsToPrint: [Identifiable]) {
      for (itemNumber, item) in itemsToPrint.enumerate() {
          print("\(itemNumber): \(item.identifier)")
      }
  }
  
  func printNames(itemsToPrint: [Namable]) {
      for (itemNumber, item) in itemsToPrint.enumerate() {
          print("\(itemNumber): \(item.name)")
      }
  }
  </code></pre>
  
  <p>And then two structs that conform to those protocols:</p>
  
  <pre><code>struct Friend: Identifiable, Namable {
      var identifier: Int
      var name: String
  }
  
  struct Dog: Identifiable, Namable {
      var identifier: Int
      var name: String
  }
  </code></pre>
  
  <p>And then say I have an array of items that conform to both those protocols:</p>
  
  <pre><code>let jeff = Friend(identifier: 232314, name: "Jeff")
  let fido = Dog(identifier: 45678, name: "Fido")
  let identifiableAndNamableItems: [protocol&lt;Identifiable, Namable&gt;] = [jeff, fido]
  </code></pre>
  
  <p>Swift has no problem when I assign <code>jeff</code> to a variable that's <code>Namable</code>:</p>
  
  <pre><code>let namableJeff: Namable = jeff //This is fine!
  </code></pre>
  
  <p>But it freaks out when I try to do:</p>
  
  <pre><code>printNames(identifiableAndNamableItems)
  </code></pre>
  
  <blockquote>
    <p>Cannot convert value of type [protocol&lt;Identifiable, Namable>] to
    expected argument type [Namable]</p>
  </blockquote>
  
  <p>Any idea why? Swift knows intuitively that a variable with type <code>protocol&lt;Identifiable, Namable&gt;</code> can be assigned to a variable with type <code>Namable</code>, since any object that conforms to two protocols must necessarily conform to just one of the protocols. But it does not understand that an array of items that conform to two protocols can be assigned to an array of items that conform to one of the protocols.</p>