<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">You are correct. Whether override `hashValue` is basing on the implementation of `==`. You can't do what you want. You should follow the required rules. However, if you don't want to get the unexpected result, you can always use a `convenience init(_ instance:Self)` in `extension` to convert subclass to superclass as I did in previous replies.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 3, 2016 at 10:12 AM, Dmitri Gribenko <span dir="ltr"><<a href="mailto:gribozavr@gmail.com" target="_blank">gribozavr@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sat, Sep 3, 2016 at 4:47 AM, Zhao Xin via swift-users<br>
<<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br>
> Hi Jordan,<br>
><br>
> Both you and I were wrong.<br>
><br>
> My wrongness: Your so called principle should be applied here.<br>
><br>
> Your wrongness: If you really want a different hash value, the parent<br>
> equality function has to be conservative and say that the different types<br>
> are different.<br>
<br>
</span>That's one way you can satisfy the rules, but not the only one.<br>
<br>
Think about class clusters. NSString has many subclasses that store<br>
strings in different ways (for example, as Latin1 and UTF-16), but any<br>
subclass instance compares equal to any other subclass instance that<br>
carries the same character data, and also produces the same hash<br>
value.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=<wbr>2;j<i;j++){if(!(i%j)){j=0;<wbr>break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
</font></span></blockquote></div><br></div>