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>Nullsafe__Nullability (infer.Nullsafe__Nullability)</title><linkrel="stylesheet"href="../../odoc.css"/><metacharset="utf-8"/><metaname="generator"content="odoc 1.5.1"/><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>» Nullsafe__Nullability</nav><h1>Module <code>Nullsafe__Nullability</code></h1></header><divclass="spec module"id="module-F"><ahref="#module-F"class="anchor"></a><code><spanclass="keyword">module</span> F = Stdlib.Format</code></div><aside><p>Nullability is a central concept for Nullsafe type-checker. Informally, nullability is a "type" \- set of values together with some additional context. All nullsafe is interested about if whether a value can be null, and if it can, what are potential causes of leaking the null inside it. Formally, nullability values form a lattice with partial order and upper bound operations. Practically, most of nullsafe core should remain agnostic over exact values of nullability (e.g. pattern-mathching over them should be a rare case. Core of typechecker should deal with subtyping and joins instead.)</p></aside><dl><dtclass="spec type"id="type-t"><ahref="#type-t"class="anchor"></a><code><spanclass="keyword">type</span> t</code><code> = </code><tableclass="variant"><trid="type-t.Null"class="anchored"><tdclass="def constructor"><ahref="#type-t.Null"class="anchor"></a><code>| </code><code><spanclass="constructor">Null</span></code></td><tdclass="doc"><p>The only possible value for that type is null</p></td></tr><trid="type-t.Nullable"class="anchored"><tdclass="def constructor"><ahref="#type-t.Nullable"class="anchor"></a><code>| </code><code><spanclass="constructor">Nullable</span></code></td><tdclass="doc"><p>No guarantees on the nullability</p></td></tr><trid="type-t.ThirdPartyNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.ThirdPartyNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">ThirdPartyNonnull</span></code></td><tdclass="doc"><p>Values coming from third-party methods and fields not explictly annotated neither as <code>@Nullable</code>, nor as <code>@Nonnull</code>. We still consider those as non-nullable but with the least level of confidence.</p></td></tr><trid="type-t.UncheckedNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.UncheckedNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">UncheckedNonnull</span></code></td><tdclass="doc"><p>The type comes from a signature that is annotated (explicitly or implicitly according to conventions) as non-nullable. Hovewer, the class is not checked under <code>@Nullsafe</code>, so its actual nullability is not truthworhy, as the class might contain arbitrary number of nullability issues</p></td></tr><trid="type-t.LocallyTrustedNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.LocallyTrustedNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">LocallyTrustedNonnull</span></code></td><tdclass="doc"><p>The same as <code>UncheckedNonnull</code>, but the value comes from a class explicitly listed as trusted in the class under analysis. It is less truthworthy than <code>LocallyCheckedNonnull</code> as no actual verification were performed.</p></td></tr><trid="type-t.LocallyCheckedNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.LocallyCheckedNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">LocallyCheckedNonnull</span></code></td><tdclass="doc"><p>Non-nullable value that comes from a class checked under <code>@NullsafeLocal</code> mode. Local mode type-checks files against its dependencies but does not require the dependencies to be transitively checked. Therefore this type of non-nullable value is differentiated from StrictNonnull.</p></td></tr><trid="type-t.ProvisionallyNullable"class="anchored"><tdclass="def constructor"><ahref="#type-t.ProvisionallyNullable"class="anchor"></a><code>| </code><code><spanclass="constructor">ProvisionallyNullable</span></code></td><tdclass="doc"><p>Only for "annotation graph" mode. Indicates the value coming from a not annotated object in the class under analysis. Since the object is not annotated, it should be treated as non-null for all cases related to user-facing issue generation.</p></td></tr><trid="type-t.StrictNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.StrictNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">StrictNonnull</span></code></td><tdclass="doc"><p>Non-nullable value with the highest degree of certainty, because it is either:</p><ul><li>a non-null literal,</li><li>an expression that semantically cannot be null,</li><li>comes from code checked under <code>@NullsafeStrict</code> mode,</li><li>comes from a third-party method with an appropriate built-in model, user-defined nullability signature, or explicit <code>@NonNull</code> annotation.</li></ul><p>The latter two are potential sources of unsoundness issues for nullsafe, but we need to strike the balance between the strictness of analysis, convenience, and real-world risk.</p></td></tr></table></dt></dl><div><divclass="spec include"><divclass="doc"><dl><dtclass="spec value"id="val-compare"><ahref="#val-compare"class="anchor"></a><code><spanclass="keyword">val</span> compare : <ahref="index.html#type-t">t</a><span>-></span><ahref="index.html#type-t">t</a><span>-></span> int</code></dt><dtclass="spec value"id="val-equal"><ahref="#val-equal"class="anchor"></a><code><spanclass="keyword">val</span> equal : <ahref="index.html#type-t">t</a><span>-></span><ahref="index.html#type-t">t</a><span>-></span> bool</code></dt></dl></div></div></div><dl><dtclass="spec type"id="type-pair"><ahref="#type-pair"class="anchor"></a><code><spanclass="keyword">type</span> pair</code><code> = <ahref="index.html#type-t">t</a> * <ahref="index.html#type-t">t</a></code></dt></dl><div><divclass="spec include"><divclass="doc"><dl><dtclass="spec value"id="val-compare_pair"><ahref="#val-compare_pair"class="anchor"></a><code><spanclass="keyword">val</span> compare_pair : <ahref="index.html#type-pair">pair</a><span>-></span><ahref="index.html#type-pair">pair</a><span>-></span> int</code></dt><dtclass="spec value"id="val-equal_pair"><ahref="#val-equal_pair"class="anchor"></a><code><spanclass="keyword">val</span> equal_pair : <ahref="index.html#type-pair">pair</a><span>-></span><ahref="index.html#type-pair">pair</a><span>-></span> bool</code></dt></dl></div></div></div><dl><dtclass="spec value"id="val-top"><ahref="#val-top"class="anchor"></a><code><spanclass="keyword">val</span> top : <ahref="index.html#type-t">t</a></code></dt><dd><p>The most generic type.</p></dd></dl><dl><dtclass="spec value"id="val-is_subtype"><ahref="#val-is_subtype"class="anchor"></a><code><spanclass="keyword">val</span> is_subtype : <span>subtype:<ahref="index.html#type-t">t</a></span><span>-></span><span>supertype:<ahref="index.html#type-t">t</a></span><span>-></span> bool</code></dt><dd><p>A is a subtype of B, if all values of A can be represented in B. Subtype relation is reflexive: everything is a subtype of itself.</p></dd></dl><dl><dtclass="spec value"id="val-join"><ahref="#val-join"class="anchor"></a><code><spanclass="keyword">val</span> join : <ahref="index.html#type-t">t</a><span>-></span><ahref="index.html#type-t">t</a><span>-></span><ahref="index.html#type-t">t</a></code></dt><dd><p>Unique upper bound over two types: the most precise type that is a supertype of both. Practically, joins occur e.g. when two branches of execution flow are getting merged.</p></dd></dl><dl><dtclass="spec value"id="val-is_considered_nonnull"><ahref="#val-is_considered_nonnull"class="anchor"></a><code><spanclass="keyword">val</span> is_considered_nonnull : <span>nullsafe_mode:<ahref="../Nullsafe/NullsafeMode/index.html#type-t">Nullsafe.NullsafeMode.t</a></span><span>-></span><ahref="index.html#type-t">t</a><span>-></span> bool</code></dt><dd><p>Check whether a given nullability is considered non-nullable within a given <code>nullsafe_mode</code>.</p></dd></dl><dl><dtclass="spec value"id="val-is_nonnullish"><ahref="#val-is_nonnullish"class="anchor"></a><code><spanclass="keyword">val</span> is_nonnullish : <ahref="index.html#type-t">t</a><span>-></span> bool</code></dt><dd><p>Check whether a given nullability is one of the non-nullable types with no regards to the mode.</p></dd></dl><dl><dtclass="spec value"id="val-pp"><ahref="#val-pp"class="anchor"></a><code><spanclass="keyword">val</span> pp : <ahref="index.html#module-F">F</a>.formatter <span>-></span><ahref="index.html#type-t">t</a><span>-></span> unit</code></dt></dl></div></body></html>