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
8.5 KiB

This file contains ambiguous Unicode 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>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Nullsafe__Nullability (infer.Nullsafe__Nullability)</title><link rel="stylesheet" href="../../odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 1.5.0"/><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; Nullsafe__Nullability</nav><h1>Module <code>Nullsafe__Nullability</code></h1></header><div class="spec module" id="module-F"><a href="#module-F" class="anchor"></a><code><span class="keyword">module</span> F = Stdlib.Format</code></div><aside><p>Nullability is a central concept for Nullsafe type-checker. Informally, nullability is a &quot;type&quot; \- 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><dt class="spec type" id="type-t"><a href="#type-t" class="anchor"></a><code><span class="keyword">type</span> t</code><code> = </code><table class="variant"><tr id="type-t.Null" class="anchored"><td class="def constructor"><a href="#type-t.Null" class="anchor"></a><code>| </code><code><span class="constructor">Null</span></code></td><td class="doc"><p>The only possible value for that type is null</p></td></tr><tr id="type-t.Nullable" class="anchored"><td class="def constructor"><a href="#type-t.Nullable" class="anchor"></a><code>| </code><code><span class="constructor">Nullable</span></code></td><td class="doc"><p>No guarantees on the nullability</p></td></tr><tr id="type-t.ThirdPartyNonnull" class="anchored"><td class="def constructor"><a href="#type-t.ThirdPartyNonnull" class="anchor"></a><code>| </code><code><span class="constructor">ThirdPartyNonnull</span></code></td><td class="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><tr id="type-t.UncheckedNonnull" class="anchored"><td class="def constructor"><a href="#type-t.UncheckedNonnull" class="anchor"></a><code>| </code><code><span class="constructor">UncheckedNonnull</span></code></td><td class="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><tr id="type-t.LocallyTrustedNonnull" class="anchored"><td class="def constructor"><a href="#type-t.LocallyTrustedNonnull" class="anchor"></a><code>| </code><code><span class="constructor">LocallyTrustedNonnull</span></code></td><td class="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><tr id="type-t.LocallyCheckedNonnull" class="anchored"><td class="def constructor"><a href="#type-t.LocallyCheckedNonnull" class="anchor"></a><code>| </code><code><span class="constructor">LocallyCheckedNonnull</span></code></td><td class="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><tr id="type-t.StrictNonnull" class="anchored"><td class="def constructor"><a href="#type-t.StrictNonnull" class="anchor"></a><code>| </code><code><span class="constructor">StrictNonnull</span></code></td><td class="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><div class="spec include"><div class="doc"><dl><dt class="spec value" id="val-compare"><a href="#val-compare" class="anchor"></a><code><span class="keyword">val</span> compare : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> int</code></dt><dt class="spec value" id="val-equal"><a href="#val-equal" class="anchor"></a><code><span class="keyword">val</span> equal : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> bool</code></dt></dl></div></div></div><dl><dt class="spec type" id="type-pair"><a href="#type-pair" class="anchor"></a><code><span class="keyword">type</span> pair</code><code> = <a href="index.html#type-t">t</a> * <a href="index.html#type-t">t</a></code></dt></dl><div><div class="spec include"><div class="doc"><dl><dt class="spec value" id="val-compare_pair"><a href="#val-compare_pair" class="anchor"></a><code><span class="keyword">val</span> compare_pair : <a href="index.html#type-pair">pair</a> <span>&#45;&gt;</span> <a href="index.html#type-pair">pair</a> <span>&#45;&gt;</span> int</code></dt><dt class="spec value" id="val-equal_pair"><a href="#val-equal_pair" class="anchor"></a><code><span class="keyword">val</span> equal_pair : <a href="index.html#type-pair">pair</a> <span>&#45;&gt;</span> <a href="index.html#type-pair">pair</a> <span>&#45;&gt;</span> bool</code></dt></dl></div></div></div><dl><dt class="spec value" id="val-top"><a href="#val-top" class="anchor"></a><code><span class="keyword">val</span> top : <a href="index.html#type-t">t</a></code></dt><dd><p>The most generic type.</p></dd></dl><dl><dt class="spec value" id="val-is_subtype"><a href="#val-is_subtype" class="anchor"></a><code><span class="keyword">val</span> is_subtype : <span>subtype:<a href="index.html#type-t">t</a></span> <span>&#45;&gt;</span> <span>supertype:<a href="index.html#type-t">t</a></span> <span>&#45;&gt;</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><dt class="spec value" id="val-join"><a href="#val-join" class="anchor"></a><code><span class="keyword">val</span> join : <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> <a href="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><dt class="spec value" id="val-is_considered_nonnull"><a href="#val-is_considered_nonnull" class="anchor"></a><code><span class="keyword">val</span> is_considered_nonnull : <span>nullsafe_mode:<a href="../Nullsafe/NullsafeMode/index.html#type-t">Nullsafe.NullsafeMode.t</a></span> <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</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><dt class="spec value" id="val-is_nonnullish"><a href="#val-is_nonnullish" class="anchor"></a><code><span class="keyword">val</span> is_nonnullish : <a href="index.html#type-t">t</a> <span>&#45;&gt;</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><dt class="spec value" id="val-pp"><a href="#val-pp" class="anchor"></a><code><span class="keyword">val</span> pp : <a href="index.html#module-F">F</a>.formatter <span>&#45;&gt;</span> <a href="index.html#type-t">t</a> <span>&#45;&gt;</span> unit</code></dt></dl></div></body></html>