This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
<!DOCTYPE html>
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><title>OverAnnotatedRule (infer.Nullsafe.OverAnnotatedRule)</title><linkrel="stylesheet"href="../../../odoc.css"/><metacharset="utf-8"/><metaname="generator"content="odoc 1.5.0"/><metaname="viewport"content="width=device-width,initial-scale=1.0"/><scriptsrc="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body><divclass="content"><header><nav><ahref="../index.html">Up</a>–<ahref="../../index.html">infer</a>»<ahref="../index.html">Nullsafe</a>» OverAnnotatedRule</nav><h1>Module <code>Nullsafe.OverAnnotatedRule</code></h1></header><aside><p>Checks if a type in signature (e.g. return value) can be made more specific. NOTE: This rule is complementatary to assignment rule. While assignment rule checks a single assignment `lhs = rhs`, this rule checks checks ALL assignments to `lhs` in the program. NOTE: Violation of this rule is not a type violation, hence it should never be surfaced as error: `lhs`'s type can be intentionally made broad by code author (e.g. to anticipate future changes in the implementation). Heuristits are required to correctly surface overannotated rule to the user. This rule is useful for some scenarios, especially for nullability code conversions when it is expected that some signatures were annotated with <code>@Nullable</code> defensively, so surfacing such cases can improve API and make migration smooth.</p></aside><dl><dtclass="spec type"id="type-violation"><ahref="#type-violation"class="anchor"></a><code><spanclass="keyword">type</span> violation</code></dt></dl><div><divclass="spec include"><divclass="doc"><dl><dtclass="spec value"id="val-compare_violation"><ahref="#val-compare_violation"class="anchor"></a><code><spanclass="keyword">val</span> compare_violation : <ahref="index.html#type-violation">violation</a><span>-></span><ahref="index.html#type-violation">violation</a><span>-></span> int</code></dt></dl></div></div></div><dl><dtclass="spec value"id="val-check"><ahref="#val-check"class="anchor"></a><code><spanclass="keyword">val</span> check : <span>what:<ahref="../Nullability/index.html#type-t">Nullability.t</a></span><span>-></span><span>by_rhs_upper_bound:<ahref="../Nullability/index.html#type-t">Nullability.t</a></span><span>-></span><span><span>(unit,<ahref="index.html#type-violation">violation</a>)</span><ahref="../../IStdlib/index.html#module-IStd">IStdlib.IStd</a>.result</span></code></dt><dd><p>Checks if the declared type for `what` can be narrowed, based on the information about all assignments `what = rhs_i`. If an upper bound of `rhs_i` over ALL assignents `what = rhs_i` that exist in the program is a _strict_ subtype of lhs, `lhs`'s type can be narrowed to be that upper bound.</p></dd></dl><dl><dtclass="spec type"id="type-violation_type"><ahref="#type-violation_type"class="anchor"></a><code><spanclass="keyword">type</span> violation_type</code><code> = </code><tableclass="variant"><trid="type-violation_type.FieldOverAnnoted"class="anchored"><tdclass="def constructor"><ahref="#type-violation_type.FieldOverAnnoted"class="anchor"></a><code>| </code><code><spanclass="constructor">FieldOverAnnoted</span><spanclass="keyword">of</span><ahref="../../IR/Fieldname/index.html#type-t">IR.Fieldname.t</a></code></td></tr><trid="type-violation_type.ReturnOverAnnotated"class="anchored"><tdclass="def constructor"><ahref="#type-violation_type.ReturnOverAnnotated"class="anchor"></a><code>| </code><code><spanclass="constructor">ReturnOverAnnotated</span><spanclass="keyword">of</span><ahref="../../IR/Procname/index.html#type-t">IR.Procname.t</a></code></td><tdclass="doc"><p>Return value of a method can be made non-nullable</p></td></tr></table></dt></dl><div><divclass="spec include"><divclass="doc"><dl><dtclass="spec value"id="val-compare_violation_type"><ahref="#val-compare_violation_type"class="anchor"></a><code><spanclass="keyword">val</span> compare_violation_type : <ahref="index.html#type-violation_type">violation_type</a><span>-></span><ahref="index.html#type-violation_type">violation_type</a><span>-></span> int</code></dt></dl></div></div></div><dl><dtclass="spec value"id="val-violation_description"><ahref="#val-violation_description"class="anchor"></a><code><spanclass="keyword">val</span> violation_description : <ahref="index.html#type-violation">violation</a><span>-></span><ahref="index.html#type-violation_type">violation_type</a><span>-></span> string</code></dt></dl></div></body></html>