<div dir="ltr">I’ve stumbled upon an odd situation where Swift gives a compiler error if I do things directly, but works properly with no error if I first create a typealias. Here is a stripped-down example:<div><br></div><div><div><font face="monospace, monospace">protocol P {</font></div><div><font face="monospace, monospace">    associatedtype C: Collection</font></div><div><font face="monospace, monospace">}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">extension P {</font></div><div><font face="monospace, monospace">    func emptyArray() -&gt; [C.Iterator.Element] {</font></div><div><font face="monospace, monospace">        return [C.Iterator.Element]()   // Error</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>The “return” line gives the error “Cannot call value of non-function type &#39;[Self.C.Iterator.Element.Type]&#39;” in Xcode 8.3.2. However, if we replace that function with a seemingly-equivalent version that uses a typealias, there is no error:</div><div><br></div><div><div><font face="monospace, monospace">extension P {</font></div><div><font face="monospace, monospace">    func emptyArray() -&gt; [C.Iterator.Element] {</font></div><div><font face="monospace, monospace">        typealias E = C.Iterator.Element</font></div><div><font face="monospace, monospace">        return [E]()    // Works</font></div><div><font face="monospace, monospace">    }</font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>Is this a known bug?</div><div><br></div><div>Nevin</div></div>