title: Cannot assign class instance to its protocol type?
body: <p>Please see self containing example below. Compiler reports an error on the last line (marked by <code>COMPILE ERROR</code>) where I am assigning an instance of <code>SimpleTrain</code> to a protocol type that it (in my best judgement) conforms to. How can I make it compile? What am I doing wrong? Or is this compiler issue?</p>
  
  <pre><code>protocol Train {
      typealias CarriageType
  
      func addCarriage(carriage: CarriageType)
      func shortTrain&lt;ShortType: Train where ShortType.CarriageType == CarriageType&gt;() -&gt; ShortType
  }
  
  class SimpleTrain&lt;T&gt; : Train {
      typealias CarriageType = T
      private var carriages: [T] = [T]()
  
      func addCarriage(carriage: T) {
         carriages.append(carriage)
      }
  
      func shortTrain&lt;ShortType: Train where ShortType.CarriageType == CarriageType&gt;() -&gt; ShortType {
          let short = SimpleTrain&lt;T&gt;()
          short.addCarriage(carriages[0])
          return short //COMPILE ERROR: SimpleTrain&lt;T&gt; is not convertible to 'ShortType'
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT:</strong> Even when I explicitly downcast the <code>shortTrain</code>'s return type above (so that last line of code snippet above reads <code>return short as ShortType</code>) as <a href="https://stackoverflow.com/a/26271483/311865">suggested by Antonio</a> there is still compilation error when calling function <code>shortTrain</code>:</p>
  
  <pre><code>let s = SimpleTrain&lt;String&gt;()
  s.addCarriage("Carriage 1")
  s.addCarriage("Carriage 2")
  
  let a = s.shortTrain() //ERROR: Cannot convert the expression's type '()' to type 'Train'
  let b = s.shortTrain&lt;SimpleTrain&lt;String&gt;&gt;() //ERROR: cannot explicitly specialize a generic function
  </code></pre>