<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">You can try this.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default"><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Container : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">class</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">var</span><span style="font-variant-ligatures:no-common-ligatures"> component: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">Component</span><span style="font-variant-ligatures:no-common-ligatures"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">get</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">}</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">class</span><span style="font-variant-ligatures:no-common-ligatures"> ConcreteContainer : </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">Container</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">lazy</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">var</span><span style="font-variant-ligatures:no-common-ligatures"> component: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">Component</span><span style="font-variant-ligatures:no-common-ligatures"> = { </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">return</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">Component</span><span style="font-variant-ligatures:no-common-ligatures">(container: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">self</span><span style="font-variant-ligatures:no-common-ligatures">) }()</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">}</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0);min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">class</span><span style="font-variant-ligatures:no-common-ligatures"> Component {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">unowned</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-variant-ligatures:no-common-ligatures"> container: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">Container</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">init</span><span style="font-variant-ligatures:no-common-ligatures">(container: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">Container</span><span style="font-variant-ligatures:no-common-ligatures">) {</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">self</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)">container</span><span style="font-variant-ligatures:no-common-ligatures"> = container</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    }</span></p>
<p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">}</span></p><p style="font-family:Menlo;margin:0px;font-size:11px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;line-height:normal;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><font face="georgia, serif">Zhaoxin</font></span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 29, 2017 at 11:48 PM, Anton Bronnikov <span dir="ltr">&lt;<a href="mailto:anton.bronnikov@me.com" target="_blank">anton.bronnikov@me.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Like I mentioned, it is necessary to use optional, but it can not be nil.  Consider the following example where I have to use an optional in order to break retention cycle:<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Container : </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">class</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> component: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Component</span><span style="font-variant-ligatures:no-common-ligatures"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">get</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal;min-height:13px"><br></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">class</span><span style="font-variant-ligatures:no-common-ligatures"> ConcreteContainer : </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Container</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> component: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Component</span><span style="font-variant-ligatures:no-common-ligatures">! = </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">nil</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">init</span><span style="font-variant-ligatures:no-common-ligatures">() {</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">component</span><span style="font-variant-ligatures:no-common-ligatures"> = </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Component</span><span style="font-variant-ligatures:no-common-ligatures">(container: </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">self</span><span style="font-variant-ligatures:no-common-ligatures">)</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal;min-height:13px"><br></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">class</span><span style="font-variant-ligatures:no-common-ligatures"> Component {</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">unowned</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> container: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Container</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">init</span><span style="font-variant-ligatures:no-common-ligatures">(container: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Container</span><span style="font-variant-ligatures:no-common-ligatures">) {</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">        </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">self</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">container</span><span style="font-variant-ligatures:no-common-ligatures"> = container</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">    }</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>Playground execution failed: error: scratchpad.playground:5:7: error: type &#39;ConcreteContainer&#39; does not conform to protocol &#39;Container&#39;</b></span></div></span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>class ConcreteContainer : Container {</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>      ^</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal;min-height:13px"><br></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>scratchpad.playground:2:9: note: protocol requires property &#39;component&#39; with type &#39;Component&#39;; do you want to add a stub?</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>    var component: Component { get }</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>        ^</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal;min-height:13px"><br></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>scratchpad.playground:6:9: note: candidate has non-matching type &#39;Component!&#39;</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>    var component: Component! = nil</b></span></div></span></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><b>        ^</b></span></div></span></div></div></div></blockquote><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"></span></div></div></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="margin:0px;line-height:normal"><div style="margin:0px;line-height:normal;min-height:13px"><br><span style="font-variant-ligatures:no-common-ligatures"></span></div></div></div></div><div><div><span style="font-variant-ligatures:no-common-ligatures">Cheers,</span></div><div><span style="font-variant-ligatures:no-common-ligatures">Anton</span></div><div><br></div><div>P.S. Declaring protocol as</div><div><br></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Container : </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">class</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div></div></div><div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> component: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Component</span><span style="font-variant-ligatures:no-common-ligatures">! { </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">get</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div></div></div><div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></div></blockquote><div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures">.. would also work of course, but my question is not about how to move forward, rather about whether such setup is deliberate.</span></div><div><div class="h5"><div><br></div><div><br><div><blockquote type="cite"><div>On 29 May 2017, at 08:20, Zhao Xin &lt;<a href="mailto:owenzx@gmail.com" target="_blank">owenzx@gmail.com</a>&gt; wrote:</div><br class="m_-6646682164546055397Apple-interchange-newline"><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Why you have to use `<span style="font-size:12.800000190734863px;font-family:arial,sans-serif">unwrapped optional` at the first place? If you have to use it, it means it could be nil. So it won&#39;t conform the protocol, which requires the `value` never nil.</span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:Menlo;font-size:11px;font-variant-ligatures:no-common-ligatures;color:rgb(52,149,175)"><br></span></div><div class="gmail_default"><font face="georgia, serif">Zhaoxin</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 29, 2017 at 12:37 PM, Anton Bronnikov via swift-users <span dir="ltr">&lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi All,<div><br></div><div>If I have a protocol with a property requirement such as:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(4,51,255)"><span style="font-variant-ligatures:no-common-ligatures">protocol</span><span style="font-variant-ligatures:no-common-ligatures"> Foo {</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> value: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Int</span><span style="font-variant-ligatures:no-common-ligatures"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">get</span><span style="font-variant-ligatures:no-common-ligatures"> }</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></blockquote><div><br></div><div>.. and I need to conform to it using an implicitly unwrapped optional like:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">struct</span><span style="font-variant-ligatures:no-common-ligatures"> Bar : </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Foo</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> value: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Int</span><span style="font-variant-ligatures:no-common-ligatures">! = </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">nil</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></blockquote><div><br></div><div>.. then the compiler fails with an error:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>Playground execution failed: error: scratchpad.playground:5:8: error: type &#39;Bar&#39; does not conform to protocol &#39;Foo&#39;</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>struct Bar : Foo {</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>       ^</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>scratchpad.playground:2:9: note: protocol requires property &#39;value&#39; with type &#39;Int&#39;; do you want to add a stub?</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>    var value: Int { get }</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>        ^</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>scratchpad.playground:6:9: note: candidate has non-matching type &#39;Int!&#39;</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>    let value: Int! = nil</b></span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><b>        ^</b></span></div></div></blockquote><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span style="font-variant-ligatures:no-common-ligatures"><b></b></span></div></div><div>Technically, I understand why the error, and currently work around it with a cumbersome:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">struct</span><span style="font-variant-ligatures:no-common-ligatures"> Bar : </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Foo</span><span style="font-variant-ligatures:no-common-ligatures"> {</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">var</span><span style="font-variant-ligatures:no-common-ligatures"> value: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Int</span><span style="font-variant-ligatures:no-common-ligatures"> { </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">return</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">_value</span><span style="font-variant-ligatures:no-common-ligatures">! }</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">    </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">let</span><span style="font-variant-ligatures:no-common-ligatures"> _value: </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af">Int</span><span style="font-variant-ligatures:no-common-ligatures">? = </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff">nil</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">}</span></div></div></blockquote><div><br></div><div>However, I keep wondering - would it not be making sense to accept implicitly unwrapped optionals as a conformance to be base-type requirements?  It sort of works just like that in all other parts of the language.</div><div><br></div><div>Or in other words, is this by design, or should I probably create an issue for this?</div><div><br></div><div>Thank you.</div><div>Cheers,</div><div>Anton</div><div><br></div><div>P.S. The example is oversimplified for the sake of clarity, in practice the property just has to be an optional - implicitly unwrapped or not - because it’s a part of the composite that holds unowning reference to its container object.</div><div><br></div></div><br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>