<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="">Hello everyone !<div class=""><br class=""></div><div class="">I am currently writing a project where I would like to do something similar to this:</div><div class=""><br class=""></div><div class=""><font color="#606060" class=""><b class="">protocol ProtocolA {<br class=""> associatedtype U<br class=""> var someVariable : U { get set }<br class=""> func someFunction(_ x:U) -> U<br class="">}<br class=""><br class="">class SomeClass<T> {<br class=""> var someProperty : ProtocolA where ProtocolA.U == T<br class="">}</b></font></div><div class=""><br class=""></div><div class="">But this isn't possible so I had to implement it as a generic class:</div><div class="">class NewClass<U> { ... }</div><div class=""><br class=""></div><div class="">And now I am using it like this:</div><div class="">class SomeClass<T> {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var someProperty: NewClass<T></div><div class="">}</div><div class=""><br class=""></div><div class="">The issue here is that protocols aren't used any more with this approach, and in my case there is no "default" implementation of <i class="">myFunction</i>, so protocols where really useful!!</div><div class=""><br class=""></div><div class="">Is there a better way to do that in the current Swift version?</div><div class=""><br class=""></div><div class="">Today, I came across the proposal SE-0142 (Permit where clauses to constrain associated types), but this only seems to apply inside of protocols, what is your opinion about having similar mechanisms in classes and structs ?</div><div class=""><br class=""></div><div class="">Thank you!</div><div class=""><br class=""></div><div class="">Trevör</div></body></html>