Explain what consistitutes a more specific type

Closes GH-457
This commit is contained in:
George Peter Banyard 2021-02-18 16:22:58 +00:00
parent d446e9e831
commit 871df69f47
No known key found for this signature in database
GPG key ID: D49A095D7329F6DC

View file

@ -13,6 +13,28 @@
of its parent's method. Whereas, contravariance allows a parameter type to be less
specific in a child method, than that of its parent.
</para>
<para>
A type declaration is considered more specific in the following case:
<itemizedlist>
<listitem>
<simpara>
A type is removed from a union type
</simpara>
</listitem>
<listitem>
<simpara>
A class type is changed to a child class type
</simpara>
</listitem>
<listitem>
<simpara>
<type>float</type> is changed to <type>int</type>
</simpara>
</listitem>
</itemizedlist>
A type class is considered less specific if the opposite is true.
</para>
<sect2 xml:id="language.oop5.variance.covariance">
<title>Covariance</title>