Swift: How can I make a function with a Subclass return type conform to a protocol, where a Superclass is defined as a return type?
<p>I have a protocol, where a function is defined, the return type of a function is a <code>SuperclassType</code>.</p>

<p>In a class which conforms to the protocol I'm trying to define this function, but with a <code>SubclassType</code> return type.</p>

<p>Compiler tells me, that this class does not conform to the protocol, because obviously <code>SubclassType</code> != <code>SuperclassType</code></p>

<pre><code>protocol SomeProtocol {
  func someFunction(someParameter:SomeType) -&gt; SuperclassType?
}

class SomeClass : SomeProtocol {
  func someFunction(someParameter:SomeType) -&gt; SubclassType? {
    ...
  }
}

class SubclassType : SuperclassType { }
</code></pre>

<p>Common sense tells me, though, that <code>SubclassType</code> should be a suitable substitute for a <code>SuperclassType</code> in this matter.</p>

<p>What am I doing wrong?</p>

<p>Thanks.</p>