<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">So I was playing around with Sequences, and I came across a problem I haven't been able to solve in a decent way. I’ve reduced it to a simpler example here:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> array : [<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>] = [<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">3</span>]</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> mapArray = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">array</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">map</span> { $0 }</div><div style="margin: 0px; line-height: normal; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> flatArray = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">mapArray</span>.flatten() <span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">// Error!</span></div></div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">This last line of code prints the following error:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""><b class="">let flatArray = mapArray.flatten() // Error!</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^~~~~~~~</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">Swift.SequenceType:4:17: note: found this candidate</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; public func flatten() -&gt; FlattenSequence&lt;Self&gt;</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">Swift.CollectionType:4:17: note: found this candidate</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; public func flatten() -&gt; FlattenCollection&lt;Self&gt;</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">Swift.CollectionType:4:17: note: found this candidate</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; public func flatten() -&gt; FlattenBidirectionalCollection&lt;Self&gt;</b></div><div style="margin: 0px; line-height: normal;" class=""><b class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ^</b></div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">As far as I understand it, the error happens because several protocols extensions implement the `flatten` method, and `mapArray` (which is of type `Array&lt;Optional&lt;Int&gt;&gt;`) conforms to a few of those, which means the compiler has no way of knowing which one I intend on using.</div><div class=""><br class=""></div><div class="">How do I solve this?</div></body></html>