<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">Looks like a compiler bug, since it works with classes:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code class="hljs language-swift" style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;overflow-x:auto;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,248)"><span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">class</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">Base</span> </span>{}
<span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">class</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">Derived</span> : <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">Base</span> </span>{}

<span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">class</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">A</span> </span>{
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> x: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Base</span>? { <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">return</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Base</span>() }
}

<span class="hljs-class"><span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">class</span> <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">B</span> : <span class="hljs-title" style="color:rgb(153,0,0);font-weight:bold;color:rgb(68,85,136);font-weight:bold">A</span> </span>{
    <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">override</span> <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">var</span> x: <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Derived</span>? { <span class="hljs-keyword" style="color:rgb(51,51,51);font-weight:bold">return</span> <span class="hljs-type" style="color:rgb(68,85,136);font-weight:bold">Derived</span>() }
}
</code></pre>
<div title="MDH:PGRpdj5Mb29rcyBsaWtlIGEgY29tcGlsZXIgYnVnLCBzaW5jZSBpdCB3b3JrcyB3aXRoIGNsYXNz
ZXM6PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5gYGBzd2lmdDwvZGl2PjxkaXY+Y2xhc3MgQmFz
ZSB7fTwvZGl2PjxkaXY+Y2xhc3MgRGVyaXZlZCA6IEJhc2Uge308L2Rpdj48ZGl2Pjxicj48L2Rp
dj48ZGl2PmNsYXNzIEEgezwvZGl2PjxkaXY+PHNwYW4gY2xhc3M9ImdtYWlsLUFwcGxlLXRhYi1z
cGFuIiBzdHlsZT0id2hpdGUtc3BhY2U6IHByZTsiPgk8L3NwYW4+dmFyIHg6IEJhc2U/IHsgcmV0
dXJuIEJhc2UoKSB9PC9kaXY+PGRpdj59PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5jbGFzcyBC
IDogQSB7PC9kaXY+PGRpdj48c3BhbiBjbGFzcz0iZ21haWwtQXBwbGUtdGFiLXNwYW4iIHN0eWxl
PSJ3aGl0ZS1zcGFjZTogcHJlOyI+CTwvc3Bhbj5vdmVycmlkZSB2YXIgeDogRGVyaXZlZD8geyBy
ZXR1cm4gRGVyaXZlZCgpIH08L2Rpdj48ZGl2Pn08L2Rpdj48ZGl2PmBgYDwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div>