<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}

h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}

h1 {
        color: #000000;
        font-size: 28pt;
}

h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}

h3 {
        font-size: 18px;
}

h4 {
        font-size: 16px;
}

h5 {
        font-size: 14px;
}

h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}

hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
    display: inherit;
}

p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}

a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}

#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}

button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}

code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}

code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}

pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}

pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}

#ws { background-color: #f8f8f8; }


.bloop_markdown table {
border-collapse: collapse;  
font-family: Helvetica, arial, freesans, clean, sans-serif;  
color: rgb(51, 51, 51);  
font-size: 15px; line-height: 25px;
padding: 0; }

.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
     
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }

.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }

.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }

.bloop_markdown blockquote{
  border-left: 4px solid #dddddd;
  padding: 0 15px;
  color: #777777; }
  blockquote > :first-child {
    margin-top: 0; }
  blockquote > :last-child {
    margin-bottom: 0; }

code, pre, #ws, #message {
    word-break: normal;
    word-wrap: normal;
}

hr {
    display: inherit;
}

.bloop_markdown :first-child {
    -webkit-margin-before: 0;
}

code, pre, #ws, #message {
    font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}


.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>My question is why cannot the <code>Base</code> type override the default implementation? I might want to override it, by calling the default implementation and modifying the result for my needs.</p>

<p>Something like that:</p>

<pre><code class="swift">protocol P {
    func foo() -&gt; Int
}

extension P {
    func foo() -&gt; Int {
        return 42
    }
}

class Base : P {
    override func foo() -&gt; {
         
        return default.foo() * 100
    }
}
</code></pre>

<p>The example is kept simple.</p>

<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1489067113181481984" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">--&nbsp;<br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 9. März 2017 um 14:37:08, Matthew Johnson via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div dir="auto"><div></div><div>



<title></title>


<div><br>
<br>
Sent from my iPad</div>
<div><br>
On Mar 9, 2017, at 2:23 AM, Slava Pestov via swift-evolution
&lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;
wrote:<br>
<br></div>
<blockquote type="cite">
<div>
I think the fact that the type checker
permits ‘final’ to appear inside protocol extensions is an
oversight and this probably does not even warrant a proposal. I
don’t think allowing this was ever part of the conceptual model of
protocol extensions at any point in time (if you recall they were
introduced ‘recently’, in Swift 2). If someone put together a PR
which makes ‘final’ in protocol extensions an error in Swift 4 mode
(and a warning in 3), I would merge it.
<div class=""><br class=""></div>
<div class="">FWIW that there is one restriction around the direct
dispatch here we want to lift, but it’s not related to this
proposal.</div>
<div class=""><br class=""></div>
<div class="">If you have a base class conforming to a protocol
using default requirements, eg</div>
<div class=""><br class=""></div>
<div class="">&nbsp; protocol Proto { func f() }</div>
<div class="">&nbsp; extension Proto { func f() { } }</div>
<div class=""><br class=""></div>
<div class="">&nbsp; class Base : Proto {}</div>
<div class=""><br class=""></div>
<div class="">Currently the witness table for Base : Proto directly
references the extension method Proto.f.</div>
<div class=""><br class=""></div>
<div class="">We want to allow this, at least inside the
module:</div>
<div class=""><br class=""></div>
<div class="">class Derived {</div>
<div class="">&nbsp; override func f() {} // does not work
currently</div>
<div class="">}</div>
<div class=""><br class=""></div>
<div class="">This will mean that ‘Proto.f’ will appear in the
vtable of ‘Base’, pointing at the extension method. The conformance
will dispatch through the vtable instead of directly calling the
extension method.</div>
</div>
</blockquote>
<div><br></div>
<div>Would this allow the override to call `Proto.f` through
super?</div>
<br>
<blockquote type="cite">
<div>
<div class="">
<div class=""><br class=""></div>
<div class="">Slava
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Mar 7, 2017, at 7:23 PM, Brian King via
swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div style="font-size:12.8px" class="">Hey Folks,&nbsp;<span style="font-size:12.8px" class="">This draft proposal addresses</span>
<span style="font-size:12.8px" class="">starter bug
SR-1762.</span><span style="font-size:12.8px" class="">&nbsp;I
believe this is in scope for Swift 4 since it impacts source
compatibility</span><span style="font-size:12.8px" class="">. It's
not a very exciting proposal, but I think it will help make Swift a
little more consistent.</span></div>
<div style="font-size:12.8px" class=""><span style="font-size:12.8px" class=""><br class=""></span></div>
<div style="font-size:12.8px" class=""><span style="font-size:12.8px" class=""><a href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7" class="">https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7</a></span><br class="">
</div>
<div style="font-size:12.8px" class=""><a href="https://bugs.swift.org/browse/SR-1762" class="">https://bugs.swift.org/browse/SR-1762</a></div>
<div style="font-size:12.8px" class=""><br class=""></div>
<div style="font-size:12.8px" class="">Thanks</div>
<div style="font-size:12.8px" class=""><br class=""></div>
<div style="font-size:12.8px" class="">Brian</div>
<div style="font-size:12.8px" class="">
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class="">Introduction</h2>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""></h2>
<p style="font-size:16px;font-weight:normal;box-sizing:border-box;margin-top:0px;margin-bottom:16px" class="">This proposal suggests removing support for
the&nbsp;<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.0470588);border-radius:3px" class="">final</code>&nbsp;keyword when declaring a function in a
protocol extension. The presence of the&nbsp;<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.0470588);border-radius:3px" class="">final</code>&nbsp;keyword does not currently generate an
error message, and it does not actually modify the dispatch
behavior in any way.</p>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""><a id="gmail-user-content-motivation" class="gmail-anchor" href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#motivation" style="color:rgb(3,102,214);box-sizing:border-box;background-color:transparent;text-decoration:none;float:left;padding-right:4px;line-height:1">
</a>Motivation</h2>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""></h2>
<p style="font-size:16px;font-weight:normal;box-sizing:border-box;margin-top:0px;margin-bottom:16px" class="">In the original protocol model of Swift, a developer could
use the&nbsp;<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.0470588);border-radius:3px" class="">final</code>&nbsp;keyword when declaring a function in a
protocol extension to ensure the function could not be overridden.
This keyword has no use in Swift's current protocol model, since
functions in protocol extensions can not be overridden and will
always use direct dispatch.</p>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""><a id="gmail-user-content-detailed-design" class="gmail-anchor" href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#detailed-design" style="color:rgb(3,102,214);box-sizing:border-box;background-color:transparent;text-decoration:none;float:left;padding-right:4px;line-height:1">
</a>Detailed design</h2>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""></h2>
<p style="font-size:16px;font-weight:normal;box-sizing:border-box;margin-top:0px;margin-bottom:16px" class="">The compiler should generate an error or warning when
the&nbsp;<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.0470588);border-radius:3px" class="">final</code>&nbsp;keyword is used on a function
declaration inside of a protocol extension. This is consistent with
the use of&nbsp;<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.0470588);border-radius:3px" class="">final</code>&nbsp;in structs and enumerations.</p>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""><a id="gmail-user-content-source-compatibility" class="gmail-anchor" href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#source-compatibility" style="color:rgb(3,102,214);box-sizing:border-box;background-color:transparent;text-decoration:none;float:left;padding-right:4px;line-height:1">
</a>Source compatibility</h2>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""></h2>
<p style="font-size:16px;font-weight:normal;box-sizing:border-box;margin-top:0px;margin-bottom:16px" class="">This change will impact source compatibility. To maintain
compatibility with Swift 3, a warning will be generated in Swift 3
mode instead of an error message.</p>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""><a id="gmail-user-content-effect-on-abi-stability" class="gmail-anchor" href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#effect-on-abi-stability" style="color:rgb(3,102,214);box-sizing:border-box;background-color:transparent;text-decoration:none;float:left;padding-right:4px;line-height:1">
</a>Effect on ABI stability</h2>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""></h2>
<p style="font-size:16px;font-weight:normal;box-sizing:border-box;margin-top:0px;margin-bottom:16px" class="">This has no effect on ABI stability</p>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""><a id="gmail-user-content-effect-on-api-resilience" class="gmail-anchor" href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#effect-on-api-resilience" style="color:rgb(3,102,214);box-sizing:border-box;background-color:transparent;text-decoration:none;float:left;padding-right:4px;line-height:1">
</a>Effect on API resilience</h2>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""></h2>
<p style="font-size:16px;font-weight:normal;box-sizing:border-box;margin-top:0px;margin-bottom:16px" class="">This has no effect on API resilience</p>
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class=""><a id="gmail-user-content-alternatives-considered" class="gmail-anchor" href="https://gist.github.com/KingOfBrian/6f20c566114ac0ef54c8092d80e54ee7#alternatives-considered" style="color:rgb(3,102,214);box-sizing:border-box;background-color:transparent;text-decoration:none;float:left;padding-right:4px;line-height:1">
</a>Alternatives considered</h2>
<div style="font-size: 16px; font-weight: normal; box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class="">
<h2 style="font-family:-apple-system,blinkmacsystemfont,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;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)" class="">The only alternative would be to not fix this bug</h2>
</div>
</div>
</div>
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</div>
</blockquote>
</div>
<br class=""></div>
</div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div>
<span>_______________________________________________</span><br>
<span>swift-evolution mailing list</span><br>
<span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br>

<span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br>
</div>
</blockquote>


_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>