Why guess as to which of these is appropriate? Couldn&#39;t you support the current and all variants of this behavior by allowing access modifiers on &#39;deprecated&#39;?<br><br>* public deprecated: warning when used from a different module, behaves as though there&#39;s a public deprecated pass-through<br><br>* internal deprecated: warning when used from a different file<br><br>* fileprivate deprecated: warning when used from a different scope<br><br>* private deprecated: synonymous with deprecated for backwards compatibility, behaves like it does today<br><br>(No need for complicated parsing; SE-25 allows a higher nominal access modifier inside a lower one without warning, so it&#39;s fine to allow &#39;public deprecated&#39; to decorate a private member with no effect.)<br><br><div class="gmail_quote"><div dir="ltr">On Fri, May 5, 2017 at 13:51 Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, May 5, 2017 at 11:37 AM BJ Homer &lt;<a href="mailto:bjhomer@gmail.com" target="_blank">bjhomer@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I’ve run into this problem as well, when dealing with legacy file formats (similar to the example in the proposal), and I agree it would be nice to be able to address it. We’ve got a few “permanent” warnings in our code base right now due to this. I’m not sure whether the deprecation should be disabled for the entire file, though; perhaps it should be disabled just within the type itself? I don’t know how that would contribute to the complexity of the implementation, but it seems like we would still want to warn about deprecated accesses between two types declared in the same file.</div></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>I initially picked &quot;same file&quot; because (1) it appears to be dead simple to implement and (2) the idea that if someone is marking a definition as private in a file, they can easily go through the same file and resolve any uses of that declaration if they no longer want them. But it&#39;s possible that there are helper types that just happen to be in the same file where you&#39;d like to be warned about using those &quot;privately allowed APIs&quot;, so you&#39;re right that same-file suppression would make those harder to detect.</div><div><br></div><div>Given that, I&#39;d be open to either of these possibilities and I&#39;d love to hear what others think:</div><div><br></div><div>* Give deprecation-suppression &quot;fileprivate&quot; semantics</div><div>* Give deprecation-suppression &quot;private&quot; semantics (suppressed in the same type and in extensions of that type within the same file)</div></div></div><div dir="ltr"><div class="gmail_quote"><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br></div><div><div>-BJ Homer</div><div><br><div><div><blockquote type="cite"></blockquote></div></div></div></div></div><div style="word-wrap:break-word"><div><div><div><div><blockquote type="cite"><div>On May 5, 2017, at 12:12 PM, Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_3300314616197341469m_-4027658941510116384Apple-interchange-newline"></blockquote></div></div></div></div></div><div style="word-wrap:break-word"><div><div><div><div><blockquote type="cite"><div><div dir="ltr"><div>Hey Swift Evolvers,</div><div><br></div><div>I&#39;d like to propose a change that would suppress deprecation warnings when the reference to the deprecated declaration is in the same file as that declaration.</div><div><br></div><div>This personally affects one of my projects (Swift protocol buffers) because .proto files allow declarations to be declared as deprecated, and we&#39;d like to surface that by deprecating the equivalent declaration in the Swift code that we generate. We can&#39;t do this without generating noisy build logs, because we still need to reference the deprecated declarations to encode/decode the messages correctly; and the workarounds have significant performance penalties as described in the draft.</div><div><br></div><div>I&#39;d love some feedback from folks to know whether this—or something like it—is something that seems desirable/undesirable for the language. I&#39;ve tinkered with an implementation in a <a href="https://github.com/apple/swift/compare/master...allevato:omit-deprecation-same-file" target="_blank">branch</a> and it&#39;s fairly straightforward.</div><div><br></div>Gist link: <a href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb" target="_blank">https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb</a><div><br></div><div><br></div><div><h1 style="box-sizing:border-box;margin:0px 0px 16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;">Omit deprecation warnings for same-file references</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><li style="box-sizing:border-box">Proposal:<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-name.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">SE-0000</a></li><li style="box-sizing:border-box;margin-top:0.25em">Author(s):<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><a href="https://github.com/allevato" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">Tony Allevato</a></li><li style="box-sizing:border-box;margin-top:0.25em">Status:<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box;font-weight:600"><a href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#rationale" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">Awaiting review</a></span></li><li style="box-sizing:border-box;margin-top:0.25em">Review manager: TBD</li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-introduction" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Public API developers can use the<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">@available</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>attribute in Swift to mark APIs as<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box;font-weight:600">deprecated,</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>which will emit warnings when a user references that API to notify them that that particular API is no longer preferred or may disappear in the future.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">These warnings are emitted for<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">any</em><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>reference to a deprecated entity, including those in the same file. In some cases, however, it may be necessary and correct to continue referring to the deprecated entity privately while discouraging its external use. In these scenarios, the warnings are superfluous and generate noise in the build logs. We propose eliminating these warnings for references made in the same file.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Swift-evolution thread:<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">TBD</a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-motivation" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">As APIs evolve, declarations may become deprecated but still need to be referenced privately in order to function correctly. For example, consider an object that is serialized/parsed between a client and server. The first iteration of such a type might look like this (the examples use a strawman API to avoid tying the discussion too closely with the new coding APIs, which is not the focus):</p><div class="m_3300314616197341469m_-4027658941510116384inbox-inbox-highlight m_3300314616197341469m_-4027658941510116384inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">class</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Person</span> {
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> name<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> phoneNumber<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">?</span>

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">name</span></span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">phoneNumber</span></span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">nil</span>) {
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">name</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> name
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">phoneNumber</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> phoneNumber
  }

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">convenience</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init?</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">from</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">reader</span>: Reader) {
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> name <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> reader.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">readString</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">withKey</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>name<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>) <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> {
      <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">nil</span>
    }
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> phoneNumber <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> reader.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">readString</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">withKey</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>phoneNumber<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">name</span>: name, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">phoneNumber</span>: phoneNumber)
  }

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">write</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">to</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">writer</span>: Writer) {
    writer.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">write</span>(name, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">key</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>name<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> phoneNumber <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> phoneNumber {
      writer.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">write</span>(phoneNumber, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">key</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>phoneNumber<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    }
  }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Later, we decide that we need to support storing multiple phone numbers for a<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Person</code>. To avoid breaking source compatibility, we deprecate the old property and add a new one. We still wish the encoding/decoding process to preserve the integrity of the old data, however—for example, a middleman process used for logging should not modify the data stream, so the encoding/decoding process should not be also migrating the data. Thus, we update the class to the following:</p><div class="m_3300314616197341469m_-4027658941510116384inbox-inbox-highlight m_3300314616197341469m_-4027658941510116384inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">class</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Person</span> {
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> name<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">@available</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">*</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">deprecated</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">message</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>use &#39;phoneNumbers&#39; instead<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> phoneNumber<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">?</span>
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> phoneNumbers<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>]

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">@available</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">*</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">deprecated</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">message</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>use &#39;init(name:phoneNumbers:)&#39; instead<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">convenience</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">name</span></span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">phoneNumber</span></span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">?</span>) {
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">phoneNumber</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> phoneNumber
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">name</span>: name, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">phoneNumbers</span>: [])
  }

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">name</span></span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">phoneNumbers</span></span>: [<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>] <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> []) {
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">name</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> name
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">phoneNumber</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">nil</span>
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">phoneNumbers</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> phoneNumbers
  }

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">convenience</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init?</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">from</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">reader</span>: Reader) {
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> name <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> reader.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">readString</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">withKey</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>name<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>) <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> {
      <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">nil</span>
    }
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> phoneNumbers <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> reader.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">readStringArray</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">withKey</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>phoneNumbers<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>) <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">??</span> []
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">phoneNumber</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> reader.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">readString</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">withKey</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>phoneNumber<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">self</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">init</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">name</span>: name, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">phoneNumbers</span>: phoneNumbers)
  }

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">public</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">write</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">to</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">writer</span>: Writer) {
    writer.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">write</span>(name, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">key</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>name<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> phoneNumber <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> phoneNumber {
      writer.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">write</span>(phoneNumber, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">key</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>phoneNumber<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    }
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">!</span>phoneNumbers.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">isEmpty</span> {
      writer.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">write</span>(phoneNumbers, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">key</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>phoneNumbers<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
    }
  }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">This type is backwards-compatible with the previous version and will warn external users that they should migrate to the new version of the API; it will also have its values preserved exactly if a middleman process parses and then reserializes it.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">The problem, however, is that the references to<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">phoneNumber</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>in<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">Person</code>&#39;s<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">own methods</em><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>also emit deprecation warnings. This is undesirable because the warnings cannot be easily avoided (see workarounds below). The crux of the issue is that one of the two statements is likely to be true:</p><ol style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><li style="box-sizing:border-box"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">At the time the user deprecates something, they also have the opportunity to migrate all references to it within the same file, thus eliminating the warnings there and making the file build cleanly.</p></li><li style="box-sizing:border-box;margin-top:0.25em"><p style="box-sizing:border-box;margin-top:16px;margin-bottom:16px">At the time the user deprecates something, they must continue to reference it internally to achieve correct and performant behavior, thus making it currently impossible to achieve a clean build for the file containing that declaration.</p></li></ol><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">This proposal aims to solve the second issue.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-workarounds-and-their-problems" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#workarounds-and-their-problems" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Workarounds and their problems</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">One workaround would be to shadow deprecated declarations by making the declaration itself private (and prepending something like an underscore to the name) and then using a public passthrough property or method. The private declaration would not be deprecated while the public one would be.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">There are two main problems with this approach. First, it increases the development and maintanence cost of the deprecation because the new declaration has to be added and all internal references to the declaration must be updated.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Secondly, and more importantly, this shadowing can have significant performance penalties. Consider this example:</p><div class="m_3300314616197341469m_-4027658941510116384inbox-inbox-highlight m_3300314616197341469m_-4027658941510116384inbox-inbox-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">class</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">DirectArrayHolder</span> {
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">@available</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">*</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">deprecated</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">message</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>Use something else instead<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> array<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>] <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> []
}

<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">class</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">IndirectArrayHolder</span> {
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> _array<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>] <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> []

  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">@available</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">*</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">deprecated</span>, <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">message</span>: <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>Use something else instead<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> array<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> [<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>] {
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">get</span> { <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> _array }
    <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">set</span> { _array <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> newValue }
  }
}

<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">useDirectHolder</span>() <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> DirectArrayHolder {
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> holder <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">DirectArrayHolder</span>()
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">for</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">_</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">in</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">0</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">...</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">10_000</span> {
    holder.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">array</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">append</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>foo<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
  }
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> holder
}

<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">useIndirectHolder</span>() <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> IndirectArrayHolder {
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> holder <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">IndirectArrayHolder</span>()
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">for</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">_</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">in</span> <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">0</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">...</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">10_000</span> {
    holder.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">array</span>.<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">append</span>(<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span>foo<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-pds" style="box-sizing:border-box">&quot;</span></span>)
  }
  <span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> holder
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Behaviorally, these are the same. However, the generated code is different because the memory management semantics change due to the passthrough property. With full optimizations on,<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">useDirectHolder</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>executes in 1.360 sec while<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">useIndirectHolder</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>executes in 235.8 sec—over two orders of magnitude slower!</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">It could be argued that this performance issue is something that could be solved separately, but this should be considered just one motivating example and not the sole motivation for this proposed change.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-proposed-solution" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#proposed-solution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Proposed solution</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Do not print deprecation warnings for references to deprecated declarations that are in the same file.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">There would be no change for declarations marked<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">unavailable</code>. A declaration marked<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">unavailable</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>is making a stronger statement about its existence such that referencing it is an error; unlike marking a declaration deprecated, marking it unavailable is a breaking change for downstream clients, so the behavior of that attribute value should be unchanged whether references are in the same file or elsewhere.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-implementation-details" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#implementation-details" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Implementation details</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">A small addition would be made to<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">TypeChecker::diagnoseIfDeprecated</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>so that it returns early if the declaration is in the same source file as the reference.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-impact-on-existing-code" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#impact-on-existing-code" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Impact on existing code</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">This is not a source-breaking change. The only side effect for existing code is that deprecation warnings that were emitted for same-file references in the past will no longer be emitted.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;"><a id="m_3300314616197341469m_-4027658941510116384inbox-inbox-user-content-alternatives-considered" class="m_3300314616197341469m_-4027658941510116384inbox-inbox-anchor" href="https://gist.github.com/allevato/76f098a761147f3be5017d10a6f4ecbb#alternatives-considered" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Alternatives considered</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Omitting deprecation warnings for references in the same<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">module</em>, not only the same<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><em style="box-sizing:border-box">file</em>, was also considered. An argument could be made that deprecation warnings are intended as messaging for<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box;font-weight:600">external</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>users of an API, so drawing the line at the module level would be more appropriate than at the file level. However, modules can be large and span a broad set of APIs contributed by many developers on multi-person teams, and they may want to use the<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">@available</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>attribute to phase out particular APIs for<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><span style="box-sizing:border-box;font-weight:600">internal</span><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>use as well. Omitting deprecation warnings for anything in the same module takes that useful tool away for those users.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px">Another idea that was brought up in a<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><a href="https://bugs.swift.org/browse/SR-3357" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank">feature request</a><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>filed for this was to allow a &quot;deprecated block&quot; that would suppress all deprecation warnings inside it. This would also solve the problem motivating this proposal and is similar to the approach taken by other languages (such as Java&#39;s<span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span><code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px">@SuppressWarnings(&quot;deprecation&quot;)</code><span class="m_3300314616197341469m_-4027658941510116384inbox-inbox-Apple-converted-space"> </span>annotation), but this approach has drawbacks as well. It would not distinguish between deprecation warnings in the same file or module vs. those in other files or modules (unless modifiers were added to it, which runs the risk of adding too much complexity for too little gain). Furthermore, it has the potential to be harmful if abused—developers could surround large code blocks with the deprecation suppressor and then lose any deprecation warnings that would have been emitted for APIs used inside that block.</p></div></div></div></blockquote></div></div></div></div></div><div style="word-wrap:break-word"><div><div><div><div><blockquote type="cite"><div>
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div></div>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>