You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
3.6 KiB

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>InheritanceRule (infer.Nullsafe.InheritanceRule)</title><link rel="stylesheet" href="../../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><div class="content"><header><nav><a href="../index.html">Up</a> <a href="../../index.html">infer</a> &#x00BB; <a href="../index.html">Nullsafe</a> &#x00BB; InheritanceRule</nav><h1>Module <code>Nullsafe.InheritanceRule</code></h1></header><aside><p>Inheritance rule:</p><ol><li>Return type for an overridden method is covariant: overridden method is allowed to narrow down the return value to a subtype of the one from the base method; this means it is OK to make the return value non-null when it was nullable in the base)</li><li>Parameter type for an overridden method is contravariant. It is OK for a derived method to accept nullable in the params even if the base does not accept nullable.</li></ol><p>NOTE: Rule 1) is based on Java covariance rule for the return type. In contrast, rule 2) is nullsafe specific as Java does not support type contravariance for method params.</p></aside><dl><dt class="spec type" id="type-violation"><a href="#type-violation" class="anchor"></a><code><span class="keyword">type</span> violation</code></dt></dl><div><div class="spec include"><div class="doc"><dl><dt class="spec value" id="val-compare_violation"><a href="#val-compare_violation" class="anchor"></a><code><span class="keyword">val</span> compare_violation : <a href="index.html#type-violation">violation</a> <span>&#45;&gt;</span> <a href="index.html#type-violation">violation</a> <span>&#45;&gt;</span> int</code></dt></dl></div></div></div><dl><dt class="spec type" id="type-type_role"><a href="#type-type_role" class="anchor"></a><code><span class="keyword">type</span> type_role</code><code> = </code><table class="variant"><tr id="type-type_role.Param" class="anchored"><td class="def constructor"><a href="#type-type_role.Param" class="anchor"></a><code>| </code><code><span class="constructor">Param</span></code></td></tr><tr id="type-type_role.Ret" class="anchored"><td class="def constructor"><a href="#type-type_role.Ret" class="anchor"></a><code>| </code><code><span class="constructor">Ret</span></code></td></tr></table></dt></dl><dl><dt class="spec value" id="val-check"><a href="#val-check" class="anchor"></a><code><span class="keyword">val</span> check : <a href="index.html#type-type_role">type_role</a> <span>&#45;&gt;</span> <span>base:<a href="../Nullability/index.html#type-t">Nullability.t</a></span> <span>&#45;&gt;</span> <span>overridden:<a href="../Nullability/index.html#type-t">Nullability.t</a></span> <span>&#45;&gt;</span> <span><span>(unit, <a href="index.html#type-violation">violation</a>)</span> <a href="../../IStdlib/index.html#module-IStd">IStdlib.IStd</a>.result</span></code></dt><dd><p>See description of the rule in the header of the file. Note that formal fact of violation might or might not be reported to the user, depending on the mode. See <code>to_reportable_violation</code></p></dd></dl><dl><dt class="spec module" id="module-ReportableViolation"><a href="#module-ReportableViolation" class="anchor"></a><code><span class="keyword">module</span> <a href="ReportableViolation/index.html">ReportableViolation</a> : <span class="keyword">sig</span> ... <span class="keyword">end</span></code></dt><dd><p>Violation that needs to be reported to the user.</p></dd></dl></div></body></html>