<div dir="ltr">Thanks for your prompt responses.<div><br></div><div>Have filed a bug:</div><div><br></div><div><a href="https://bugs.swift.org/browse/SR-3840">SR-3840 - Closure picks up static type not dynamic</a><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">  -- Howard.<br></div></div>
<br><div class="gmail_quote">On 3 February 2017 at 08:57, Slava Pestov <span dir="ltr">&lt;<a href="mailto:spestov@apple.com" target="_blank">spestov@apple.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">The problem is were not marking the materializeForSet accessor in DefaultMutableReference.<wbr>value as an override. Definitely a bug:<div><br></div><div>sil_vtable DefaultMutableReference {<br>  #MutableReference.init!<wbr>initializer.1: _<wbr>TFC1d23DefaultMutableReference<wbr>cfT_GS0_x_       // DefaultMutableReference.init() -&gt; DefaultMutableReference&lt;A&gt;<br>  #MutableReference.value!<wbr>getter.1: _<wbr>TFC1d23DefaultMutableReference<wbr>g5valuex     // DefaultMutableReference.value.<wbr>getter<br>  #MutableReference.value!<wbr>setter.1: _<wbr>TFC1d23DefaultMutableReference<wbr>s5valuex     // DefaultMutableReference.value.<wbr>setter<br>  #MutableReference.value!<wbr>materializeForSet.1: _<wbr>TFC1d16MutableReferencem5value<wbr>x // MutableReference.value.<wbr>materializeForSet<br>  #DefaultMutableReference.<wbr>value!materializeForSet.1: _<wbr>TFC1d23DefaultMutableReference<wbr>m5valuex   // DefaultMutableReference.value.<wbr>materializeForSet</div><div><br></div><div>The last entry should not exist.</div><div><br></div><div>I’ll have a fix shortly.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Slava</div></font></span><div><div class="h5"><div><br><div><blockquote type="cite"><div>On Feb 2, 2017, at 9:04 AM, Jordan Rose via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br class="m_-1457122125922993085Apple-interchange-newline"><div><div style="word-wrap:break-word"><div>Seems like a bug, and moreover it seems like a regression from Swift 3.0. Mind filing a report at <a href="http://bugs.swift.org/" target="_blank">bugs.swift.org</a>?</div><div><br></div><div>Thanks!</div><div>Jordan</div><br><div><blockquote type="cite"><div>On Feb 1, 2017, at 20:49, Howard Lovatt via swift-users &lt;<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>&gt; wrote:</div><br class="m_-1457122125922993085Apple-interchange-newline"><div><div dir="ltr">Hi All,<div><br></div><div>Anyone know what is going on here:</div><div><br></div><div>    //: Closure picks up static type not dynamic</div><div>    <br>    class MutableReference&lt;T&gt; {<br>        init() {<br>            guard type(of: self) != MutableReference.self else {<br>                fatalError(&quot;MutableReference is an abstract class; create a derrivative of MutableReference&quot;)<br>            }<br>        }<br>        var value: T {<br>            get {<br>                fatalError(&quot;Calculated property value getter should be overridden&quot;)<br>            }<br>            set {<br>                fatalError(&quot;Calculated property value setter should be overridden&quot;)<br>            }<br>        }<br>    }</div><div>    <br>    class DefaultMutableReference&lt;T&gt;: MutableReference&lt;T&gt; {<br>        private var _value: T<br>        override var value: T {<br>            get {<br>                return _value<br>            }<br>            set {<br>                _value = newValue<br>            }<br>        }<br>        init(_ value: T) {<br>            _value = value<br>        }<br>    }<br><br>    let e: (MutableReference&lt;[Int]&gt;, Int) -&gt; Void = { $0.value.append($1) }<br>    let dmr = DefaultMutableReference([2])<br>    dmr.value // [2]<br>    e(dmr, 2) // fatal error: Calculated property value getter should be overridden<br>    dmr.value // Expect [2, 2]  <br><p class="m_-1457122125922993085gmail-p1">If I change `e` to:</p>    let e: (DefaultMutableReference&lt;[Int]<wbr>&gt;, Int) -&gt; Void = { $0.value.append($1) }<br><p class="m_-1457122125922993085gmail-p1">It works fine.</p><p class="m_-1457122125922993085gmail-p1">IE the closure is using the static type of its first argument and not dynamically dispatching.</p><p class="m_-1457122125922993085gmail-p1">Am I doing something wrong? Is there a way round where I can still use the base class for `e`?</p><p class="m_-1457122125922993085gmail-p1"><br></p><p class="m_-1457122125922993085gmail-p1">Thanks for any help in advance,</p><p class="m_-1457122125922993085gmail-p1">-- Howard.<br></p>
</div></div>
______________________________<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" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div>______________________________<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" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>