<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 28, 2015, at 3:43 PM, Jonathan Bailey via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Alegreya-Regular; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">In the following code, I get an error on the line indicated (4th from the bottom) that "Protocol 'APIEndPoint' can only be used as a generic constraint because it has Self or associated type requirements” I understand this is because the APIEndPoint protocol contains a type alias. However I don’t understand why this means it can’t be used as a type?</span></div></blockquote><br class=""></div><div>I finally understand the reason, after reading [a draft of] <a href="http://objc.io" class="">objc.io</a>'s <i class="">Advanced Swift</i>&nbsp;book. You can’t use such a protocol as a type because if the aliased type appears in the API, it won’t be consistent between different objects that conform to the protocol but have different aliased types. For example, if a protocol Foo has a method foo() that returns a typealias T, then different objects conforming to Foo will return different types from their foo() methods, so there’s no type-safe way to represent that return value.</div><div><br class=""></div><div>In your case you’ve got a typealias but you’re not using it in the protocol’s API. It looks like it’s just internally used inside the implementation of the urlString method. You can probably change your code around to get the same effect without using a typealias. Make baseURL a regular non-static method of API, then just have a property of APIEndpoint of type API.</div><div><br class=""></div><div>—Jens</div></body></html>