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__AnnotatedNullability (infer.Nullsafe__AnnotatedNullability)</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>» Nullsafe__AnnotatedNullability</nav><h1>Module <code>Nullsafe__AnnotatedNullability</code></h1></header><aside><p>Nullability of a type in Java program (e.g. in a function or field declaration). It might come from explicit annotations (or lack of annotation), or from other sources, including conventions about defaults, models, or the mode nullsafe runs in. NOTE: This is complementary to <spanclass="xref-unresolved"title="unresolved reference to "InferredNullability.t""><code>InferredNullability</code>.t</span>. <code>InferredNullability</code> contains info about _actual_ nullability (what did nullsafe infer according to its flow-sensitive rules.). In contrast, AnnotatedNullability represents _formal_ type as it appears in the program code. NOTE: Nullsafe disregards user-provided annotations for local types, so annotated nullability applies only for types declared at methods and field level.</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.Nullable"class="anchored"><tdclass="def constructor"><ahref="#type-t.Nullable"class="anchor"></a><code>| </code><code><spanclass="constructor">Nullable</span><spanclass="keyword">of</span><ahref="index.html#type-nullable_origin">nullable_origin</a></code></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></tr><trid="type-t.UncheckedNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.UncheckedNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">UncheckedNonnull</span><spanclass="keyword">of</span><ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a></code></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></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></tr><trid="type-t.StrictNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-t.StrictNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">StrictNonnull</span><spanclass="keyword">of</span><ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a></code></td></tr></table></dt><dd><p>See <spanclass="xref-unresolved"title="unresolved reference to "Nullability.t""><code>Nullability</code>.t</span> for explanation</p></dd></dl><dl><dtclass="spec type"id="type-nullable_origin"><ahref="#type-nullable_origin"class="anchor"></a><code><spanclass="keyword">and</span> nullable_origin</code><code> = </code><tableclass="variant"><trid="type-nullable_origin.AnnotatedNullable"class="anchored"><tdclass="def constructor"><ahref="#type-nullable_origin.AnnotatedNullable"class="anchor"></a><code>| </code><code><spanclass="constructor">AnnotatedNullable</span></code></td><tdclass="doc"><p>The type is expicitly annotated with <code>@Nullable</code> in the code</p></td></tr><trid="type-nullable_origin.AnnotatedPropagatesNullable"class="anchored"><tdclass="def constructor"><ahref="#type-nullable_origin.AnnotatedPropagatesNullable"class="anchor"></a><code>| </code><code><spanclass="constructor">AnnotatedPropagatesNullable</span></code></td><tdclass="doc"><p>If a function param is annotated as <code>@PropagatesNullable</code>, this param is automatically nullable</p></td></tr><trid="type-nullable_origin.HasPropagatesNullableInParam"class="anchored"><tdclass="def constructor"><ahref="#type-nullable_origin.HasPropagatesNullableInParam"class="anchor"></a><code>| </code><code><spanclass="constructor">HasPropagatesNullableInParam</span></code></td><tdclass="doc"><p>If a method has at least one param marked as <code>@PropagatesNullable</code>, return value is automatically nullable</p></td></tr><trid="type-nullable_origin.ModelledNullable"class="anchored"><tdclass="def constructor"><ahref="#type-nullable_origin.ModelledNullable"class="anchor"></a><code>| </code><code><spanclass="constructor">ModelledNullable</span></code></td><tdclass="doc"><p>nullsafe knows it is nullable via its internal models</p></td></tr></table></dt><dtclass="spec type"id="type-unchecked_nonnull_origin"><ahref="#type-unchecked_nonnull_origin"class="anchor"></a><code><spanclass="keyword">and</span> unchecked_nonnull_origin</code><code> = </code><tableclass="variant"><trid="type-unchecked_nonnull_origin.AnnotatedNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-unchecked_nonnull_origin.AnnotatedNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">AnnotatedNonnull</span></code></td><tdclass="doc"><p>The type is explicitly annotated as non nullable via one of nonnull annotations Nullsafe recognizes</p></td></tr><trid="type-unchecked_nonnull_origin.ImplicitlyNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-unchecked_nonnull_origin.ImplicitlyNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">ImplicitlyNonnull</span></code></td><tdclass="doc"><p>Infer was run in mode where all not annotated (non local) types are treated as non nullable</p></td></tr></table></dt><dtclass="spec type"id="type-strict_nonnull_origin"><ahref="#type-strict_nonnull_origin"class="anchor"></a><code><spanclass="keyword">and</span> strict_nonnull_origin</code><code> = </code><tableclass="variant"><trid="type-strict_nonnull_origin.ExplicitNonnullThirdParty"class="anchored"><tdclass="def constructor"><ahref="#type-strict_nonnull_origin.ExplicitNonnullThirdParty"class="anchor"></a><code>| </code><code><spanclass="constructor">ExplicitNonnullThirdParty</span></code></td><tdclass="doc"><p>Third party annotated as <code>@Nonnull</code> is considered strict. This is a controversial choice and might be an unsoundness issue. The reason is practical. The best we can do for third party is to register it in third party signature repository. Though this typically requires human review, in practice errors are inevitable. On the other hand, if the library owner explicitly annotated a function as nonnull, we assume this was made for reason. In practice, requiring such methods to be registered in third party folder, will introduce user friction but will not significantly increase safety. So our approach here is optimistic. If some particular method or library is known to contain wrong <code>@Nonnull</code> annotations, third party repository is a way to override this.</p></td></tr><trid="type-strict_nonnull_origin.ModelledNonnull"class="anchored"><tdclass="def constructor"><ahref="#type-strict_nonnull_origin.ModelledNonnull"class="anchor"></a><code>| </code><code><spanclass="constructor">ModelledNonnull</span></code></td><tdclass="doc"><p>nullsafe knows it is non-nullable via its internal models</p></td></tr><trid="type-strict_nonnull_origin.StrictMode"class="anchored"><tdclass="def constructor"><ahref="#type-strict_nonnull_origin.StrictMode"class="anchor"></a><code>| </code><code><spanclass="constructor">StrictMode</span></code></td><tdclass="doc"><p>under strict mode we consider non-null declarations to be trusted</p></td></tr><trid="type-strict_nonnull_origin.PrimitiveType"class="anchored"><tdclass="def constructor"><ahref="#type-strict_nonnull_origin.PrimitiveType"class="anchor"></a><code>| </code><code><spanclass="constructor">PrimitiveType</span></code></td><tdclass="doc"><p>Primitive types are non-nullable by language design</p></td></tr><trid="type-strict_nonnull_origin.EnumValue"class="anchored"><tdclass="def constructor"><ahref="#type-strict_nonnull_origin.EnumValue"class="anchor"></a><code>| </code><code><spanclass="constructor">EnumValue</span></code></td><tdclass="doc"><p>Java enum value are statically initialized with non-nulls according to language semantics</p></td></tr><trid="type-strict_nonnull_origin.SyntheticField"class="anchored"><tdclass="def constructor"><ahref="#type-strict_nonnull_origin.SyntheticField"class="anchor"></a><code>| </code><code><spanclass="constructor">SyntheticField</span></code></td><tdclass="doc"><p>Fake field that is not part of user codebase, but rather artifact of codegen/annotation processor</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-compare_nullable_origin"><ahref="#val-compare_nullable_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_nullable_origin : <ahref="index.html#type-nullable_origin">nullable_origin</a><span>-></span><ahref="index.html#type-nullable_origin">nullable_origin</a><span>-></span> int</code></dt><dtclass="spec value"id="val-compare_unchecked_nonnull_origin"><ahref="#val-compare_unchecked_nonnull_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_unchecked_nonnull_origin : <ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a><span>-></span><ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a><span>-></span> int</code></dt><dtclass="spec value"id="val-compare_strict_nonnull_origin"><ahref="#val-compare_strict_nonnull_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_strict_nonnull_origin : <ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a><span>-></span><ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a><span>-></span> int</code></dt><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-compare_nullable_origin"><ahref="#val-compare_nullable_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_nullable_origin : <ahref="index.html#type-nullable_origin">nullable_origin</a><span>-></span><ahref="index.html#type-nullable_origin">nullable_origin</a><span>-></span> int</code></dt><dtclass="spec value"id="val-compare_unchecked_nonnull_origin"><ahref="#val-compare_unchecked_nonnull_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_unchecked_nonnull_origin : <ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a><span>-></span><ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a><span>-></span> int</code></dt><dtclass="spec value"id="val-compare_strict_nonnull_origin"><ahref="#val-compare_strict_nonnull_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_strict_nonnull_origin : <ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a><span>-></span><ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a><span>-></span> int</code></dt><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-compare_nullable_origin"><ahref="#val-compare_nullable_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_nullable_origin : <ahref="index.html#type-nullable_origin">nullable_origin</a><span>-></span><ahref="index.html#type-nullable_origin">nullable_origin</a><span>-></span> int</code></dt><dtclass="spec value"id="val-compare_unchecked_nonnull_origin"><ahref="#val-compare_unchecked_nonnull_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_unchecked_nonnull_origin : <ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a><span>-></span><ahref="index.html#type-unchecked_nonnull_origin">unchecked_nonnull_origin</a><span>-></span> int</code></dt><dtclass="spec value"id="val-compare_strict_nonnull_origin"><ahref="#val-compare_strict_nonnull_origin"class="anchor"></a><code><spanclass="keyword">val</span> compare_strict_nonnull_origin : <ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a><span>-></span><ahref="index.html#type-strict_nonnull_origin">strict_nonnull_origin</a><span>-></span> int</code></dt></dl></div></div></div><dl><dtclass="spec value"id="val-get_nullability"><ahref="#val-get_nullability"class="anchor"></a><code><spanclass="keyword">val</span> get_nullability : <ahref="index.html#type-t">t</a><span>-></span><ahref="../Nullsafe/Nullability/index.html#type-t">Nullsafe.Nullability.t</a></code></dt><dtclass="spec value"id="val-of_type_and_annotation"><ahref="#val-of_type_and_annotation"class="anchor"></a><code><spanclass="keyword">val</span> of_type_and_annotation : <span>is_callee_in_trust_list:bool</span><span>-></span><span>nullsafe_mode:<ahref="../Nullsafe/NullsafeMode/index.html#type-t">Nullsafe.NullsafeMode.t</a></span><span>-></span><span>is_third_party:bool</span><span>-></span><ahref="../IR/Typ/index.html#type-t">IR.Typ.t</a><span>-></span><ahref="../IR/Annot/Item/index.html#type-t">IR.Annot.Item.t</a><span>-></span><ahref="index.html#type-t">t</a></code></dt><dd><p>Given the type and its annotations, returns its nullability. NOTE: it does not take into account models etc., so this is intended to be used as a helper function for more high-level annotation processing. <code>is_callee_in_trust_list</code> defines whether the callee class is in the caller's explicitly provided trust list and therefore whether its nullability should be refined.</p></dd></dl><dl><dtclass="spec value"id="val-pp"><ahref="#val-pp"class="anchor"></a><code><spanclass="keyword">val</span> pp : Stdlib.Format.formatter <span>-></span><ahref="index.html#type-t">t</a><span>-></span> unit</code></dt></dl></div></body></html>