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

This file contains invisible Unicode characters!

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>
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>OverAnnotatedRule (infer.Nullsafe.OverAnnotatedRule)</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; 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><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 value" id="val-check"><a href="#val-check" class="anchor"></a><code><span class="keyword">val</span> check : <span>what:<a href="../Nullability/index.html#type-t">Nullability.t</a></span> <span>&#45;&gt;</span> <span>by_rhs_upper_bound:<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>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><dt class="spec type" id="type-violation_type"><a href="#type-violation_type" class="anchor"></a><code><span class="keyword">type</span> violation_type</code><code> = </code><table class="variant"><tr id="type-violation_type.FieldOverAnnoted" class="anchored"><td class="def constructor"><a href="#type-violation_type.FieldOverAnnoted" class="anchor"></a><code>| </code><code><span class="constructor">FieldOverAnnoted</span> <span class="keyword">of</span> <a href="../../IR/Fieldname/index.html#type-t">IR.Fieldname.t</a></code></td></tr><tr id="type-violation_type.ReturnOverAnnotated" class="anchored"><td class="def constructor"><a href="#type-violation_type.ReturnOverAnnotated" class="anchor"></a><code>| </code><code><span class="constructor">ReturnOverAnnotated</span> <span class="keyword">of</span> <a href="../../IR/Procname/Java/index.html#type-t">IR.Procname.Java.t</a></code></td><td class="doc"><p>Return value of a method can be made non-nullable</p></td></tr></table></dt></dl><div><div class="spec include"><div class="doc"><dl><dt class="spec value" id="val-compare_violation_type"><a href="#val-compare_violation_type" class="anchor"></a><code><span class="keyword">val</span> compare_violation_type : <a href="index.html#type-violation_type">violation_type</a> <span>&#45;&gt;</span> <a href="index.html#type-violation_type">violation_type</a> <span>&#45;&gt;</span> int</code></dt></dl></div></div></div><dl><dt class="spec value" id="val-violation_description"><a href="#val-violation_description" class="anchor"></a><code><span class="keyword">val</span> violation_description : <a href="index.html#type-violation">violation</a> <span>&#45;&gt;</span> <a href="index.html#type-violation_type">violation_type</a> <span>&#45;&gt;</span> string</code></dt></dl></div></body></html>