<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Swift users,<br class=""><br class="">I¡¯m defining a sub-protocol inheriting from&nbsp;parent protocol with associatedtype, and I want to specialized the associatedtype to certain concrete type.<br class=""><br class="">For example,&nbsp;<br class=""><br class="">```swift<br class="">protocol&nbsp;Foo {<br class="">&nbsp; &nbsp;&nbsp;associatedtype&nbsp;Bar<br class="">&nbsp; &nbsp;&nbsp;<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;var&nbsp;bar: Bar {&nbsp;get&nbsp;}<br class="">}<br class="">&nbsp; &nbsp;&nbsp;<br class="">protocol&nbsp;A:&nbsp;Foo&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;// I want `Bar` to be `Int`.<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;var&nbsp;a:&nbsp;Int&nbsp;{&nbsp;get&nbsp;}<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;var&nbsp;bar:&nbsp;Int&nbsp;{&nbsp;get&nbsp;}<br class="">}<br class=""><br class="">extension&nbsp;A&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;typealias&nbsp;Bar =&nbsp;Int<br class="">}<br class="">```<br class=""><br class="">I want any class/struct adopting protocol `A` having associatedtype `Bar` specialized to Int. However, I found that structs adopting `A` are still capable of override it.<br class=""><br class="">```swift<br class="">extension A {<div class="">&nbsp; &nbsp;&nbsp;static&nbsp;var&nbsp;bar:&nbsp;Int&nbsp;{<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;return&nbsp;a<br class="">&nbsp; &nbsp;&nbsp;}</div><div class=""><br class="">&nbsp; &nbsp;&nbsp;static&nbsp;func&nbsp;test() {<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;print(bar)<br class="">&nbsp; &nbsp;&nbsp;}<br class="">}<br class=""><br class="">struct&nbsp;AStruct:&nbsp;A&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;let&nbsp;a:&nbsp;Int&nbsp;=&nbsp;0<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;let&nbsp;bar:&nbsp;Bool&nbsp;=&nbsp;false // Bar is now Bool<br class="">&nbsp; &nbsp;&nbsp;// static let bar: Int now becomes invisible.<br class="">}</div><div class=""><br class=""></div><div class="">AStruct.test() // prints 0<br class=""><div class="">```</div></div><div class=""><br class=""></div><div class="">The code above gave same result on both Swift 2.2(Xcode 7.3.1) and Swift 3.0(Xcode 8 beta 3).</div><div class=""><br class=""></div><div class="">It¡¯s this expected behavior? Or am I'm getting something wrong here? What about specializing parent¡¯s associatedtype to certain generic type with newly introduced associatedtype? For example,</div><div class=""><br class=""></div><div class="">```swift</div><span class="">protocol&nbsp;B:&nbsp;Foo&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;associatedtype&nbsp;T<br class="">&nbsp; &nbsp;&nbsp;static&nbsp;var&nbsp;bar:&nbsp;Array&lt;T&gt; {&nbsp;get&nbsp;}<br class="">}<br class=""><br class="">extension&nbsp;B&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;typealias&nbsp;Bar =&nbsp;Array&lt;T&gt;<br class="">}<br class=""></span><div class="">```</div><div class=""><br class=""></div><div class="">Any idea would be appreciated.</div><div class=""><br class=""></div><div class="">Thanks</div><div class=""><br class=""></div><div class="">Fengwei</div></body></html>