<font face="Verdana,Arial,Helvetica,sans-serif" size="2"><div style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;">Thanks John. This is the JIRA bug report:&nbsp;<a href="https://bugs.swift.org/browse/SR-4852" target="_blank">https://bugs.swift.org/browse/SR-4852</a></div><div style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;"><br></div><div style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;">I was able to write a small test case that shows the regression:</div><div style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;"><br></div><div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">enum State {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; case ready(TState)</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; case inProgress(TState)</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc"><br></font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; var isPaused: Bool {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; switch self {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; case .ready: return false</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; case .inProgress: return false</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">}</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc"><br></font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">enum Drain {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; case foo(String)</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; case bar(Int, String)</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">}</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc"><br></font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">struct TState {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; let drain: Drain</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">}</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc"><br></font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">class Task {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; var state = State.ready(TState(drain: .foo("wow"))) {&nbsp;</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; willSet {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if newValue.isPaused { }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc"><br></font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; func resume() {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; if case .ready(let tState) = state {</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("before =&gt; \(state)")</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; state = .inProgress(tState) //doesn't take effect</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print("after =&gt; \(state)")</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; &nbsp; &nbsp; }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">&nbsp; &nbsp; }</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">} &nbsp; &nbsp;</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc"><br></font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">//main</font></div><div><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000cc">Task().resume()</font></div><font size="2"><font><font><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div class="socmaildefaultfont" dir="ltr"><div dir="ltr" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif; font-style: normal;"><br><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif">Output with the latest master:</font></div><div dir="ltr" style="font-style: normal;"><p style="margin: 0px; line-height: normal;"><span style="font-variant-ligatures: no-common-ligatures;"><font face="monospace, Courier New, Courier, monospace" color="#0000cc">before =&gt; ready(Test.TState(drain: Test.Drain.foo("wow")))</font></span></p><p style="margin: 0px; line-height: normal;"><span style="font-variant-ligatures: no-common-ligatures;"><font face="monospace, Courier New, Courier, monospace" color="#0000cc">after =&gt; ready(Test.TState(drain: Test.Drain.foo("wow")))</font></span></p><div style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;"><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;"><br></div></div><div dir="ltr" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif; font-style: normal;"><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif">Expected output (and with the 04-24 snapshot as well):</font></div><div dir="ltr" style="font-style: normal;"><p style="margin: 0px; line-height: normal;"><span style="font-variant-ligatures: no-common-ligatures;"><font face="monospace, Courier New, Courier, monospace" color="#0000cc">before =&gt; ready(Test.TState(drain: Test.Drain.foo("wow")))</font></span></p><p style="margin: 0px; line-height: normal;"><span style="font-variant-ligatures: no-common-ligatures;"><font face="monospace, Courier New, Courier, monospace" color="#0000cc">after =&gt; inProgress(Test.TState(drain: Test.Drain.foo("wow")))</font></span></p><p style="font-size: 14px; font-family: Menlo; margin: 0px; line-height: normal;"><span style="font-variant-ligatures: no-common-ligatures"><br></span></p><p style="font-size: 14px; font-family: Menlo; margin: 0px; line-height: normal;"><span style="font-variant-ligatures: no-common-ligatures"><br></span></p></div><div dir="ltr" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif; font-style: normal;"><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif">Pushkar N Kulkarni,</font></div>
<div dir="ltr" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif; font-style: normal;"><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif">IBM Runtimes</font></div><div dir="ltr" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif; font-style: normal;"><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif"><br></font></div><div dir="ltr" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;"><font face="serif, Times New Roman, Times, serif"><i>Simplicity is prerequisite for reliability - Edsger W. Dijkstra</i></font></div>
<div dir="ltr" style="font-size: 10.5pt; font-family: Arial; font-style: normal;"><br></div></div></div></div></font></font></font></div><br><br><font face="Default Sans Serif,Verdana,Arial,Helvetica,sans-serif" size="2" color="#000000" style="font-size: small; font-family: Verdana, Arial, Helvetica, sans-serif;"><font color="#990099"><a href="mailto:-----rjmccall@apple.com" target="_blank">-----rjmccall@apple.com</a> wrote: -----</font><div class="iNotesHistory" style="padding-left:5px;"><div style="padding-right:0px;padding-left:5px;border-left:solid black 2px;">To: Pushkar N Kulkarni &lt;<a href="mailto:pushkar.nk@in.ibm.com" target="_blank">pushkar.nk@in.ibm.com</a>&gt;<br>From: John McCall <rjmccall@apple.com><br>Sent by: <a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a><br>Date: 05/10/2017 04:19AM<br>Cc: swift-dev &lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;<br>Subject: Re: [swift-dev] Property modification not taking effect<br><br><!--Notes ACF
<meta http-equiv="Content-Type" content="text/html charset=utf8">--><div><blockquote type="cite" class=""><div class="">On May 9, 2017, at 3:07 PM, Pushkar N Kulkarni via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><div class=""><font face="Verdana,Arial,Helvetica,sans-serif" size="2" class=""><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">In the process of debugging a bunch of consistent failures in TestFoundation/TestNSURLSession, I came across a weird problem symptom in <a target="_blank" href="https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSURLSession/NSURLSessionTask.swift#L329" title="https://github.com/apple/swift-corelibs-foundation/blob/master/Foundation/NSURLSession/NSURLSessionTask.swift#L329" class="">this line of code</a>.</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><br class=""></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><span style="font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font color="#24292e" class="">internalState </font></span><span class="pl-k" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;"><font color="#a71d5d" class="">=</font></span><span style="font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font color="#24292e" class=""> .</font></span><span class="pl-c1" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;"><font color="#0086b3" class="">transferInProgress</font></span><span style="font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font color="#24292e" class="">(transferState)</font></span><br class=""></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><span style="font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; white-space: pre;" class=""><font color="#24292e" class=""><br class=""></font></span></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">I had a suspicion that the above modification is not taking effect, since, only based on this change the didSet observer for the `internalState` property triggers data transfers using libcurl. So, I simply printed the property before and after the assignment.&nbsp;</div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><br class=""></div><div class=""><font face="monospace, Courier New, Courier, monospace" size="2" class="">print("before =&gt; \(internalState)")</font></div><div class=""><font face="monospace, Courier New, Courier, monospace" size="2" class=""><span style="white-space: pre;" class=""><font color="#24292e" class="">internalState </font></span><span class="pl-k" style="box-sizing: border-box; white-space: pre;"><font color="#a71d5d" class="">=</font></span><span style="white-space: pre;" class=""><font color="#24292e" class=""> .</font></span><span class="pl-c1" style="box-sizing: border-box; white-space: pre;"><font color="#0086b3" class="">transferInProgress</font></span><span style="white-space: pre;" class=""><font color="#24292e" class="">(transferState)</font></span><br class=""></font></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><font face="monospace, Courier New, Courier, monospace" size="2" class="">print("after =&gt; \(internalState)")</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><font face="monospace, Courier New, Courier, monospace" size="2" class=""><br class=""></font></span></div></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">Surprisingly, I don't see any change in the property value:</div><div class=""><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000ff" class="">before =&gt; transferReady(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))<br class=""></font></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000ff" class="">after &nbsp;=&gt; transferReady(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))</font></span></div></div><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><br class=""></div><div class=""><font face="Verdana, Arial, Helvetica, sans-serif" style="font-size: small;" class="">When I switched back to the "</font><font face="Sans Serif, Verdana, Arial, Helvetica, sans-serif" size="2" class="">swift-DEVELOPMENT-SNAPSHOT-2017-04-24-a"</font><span style="font-size: 14px; font-family: Menlo;" class="">&nbsp;</span><font face="Verdana, Arial, Helvetica, sans-serif" style="font-size: small;" class="">tag on all the repos (except swift-corelibs-foundation), I do not see this problem. I see:</font></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000ff" class="">before =&gt; transferReady(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))</font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><font face="monospace, Courier New, Courier, monospace" size="2" color="#0000ff" class="">after &nbsp;=&gt; transferInProgress(Foundation.URLSessionTask._TransferState(... &lt;redacted&gt; ...))</font></span></div><div style="font-family: Menlo; font-size: 14px; margin: 0px; line-height: normal;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">To put it in simple terms, the modification doesn't seem to be taking effect with the current HEAD.&nbsp;</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">I haven't been able to isolate this problem in an independent test case. However, anybody who wants to reproduce it can simply run TestFoundation after enabling the URLSession tests (which have been disabled for now) in TestFoundation/main.swift.&nbsp;</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">I did compare the `-emit-ir` outputs from the passing and failing levels. There seems to be a clear difference in the way we store the new value of this property. But given my limited exposure to debugging Swift compiler issues, I wasn't able to progress further. &nbsp;</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small;" class="">&nbsp;</span><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><font face="Verdana, Arial, Helvetica, sans-serif" size="2" class="">Can someone help us here please? Thanks.&nbsp;</font></div></div></font></div></blockquote><div><br class=""></div></div>That sounds like a serious bug; please file it in JIRA.<div class=""><br class=""></div><div class="">John.</div></rjmccall@apple.com></div></div></font></font><BR>