This annotation is intended for complex cases and is primarily designed to be used by the built-in annotations.
Overview
Some callbacks only run when a value is known to be valid. A weapon’sThink only runs while a player holds the weapon, so self:GetOwner() is always valid there, even though GetOwner can return NULL elsewhere.
self_call_valid goes on the callback and names that method. Inside the callback, calls of it on self are treated as valid.
The official annotations already mark the weapon and entity callbacks where this holds.
Syntax
Example
Keep it narrow
It applies only inside the annotated callback. Helper methods the callback calls do not get it, andGetOwner keeps its normal return type everywhere else.
See also
@valid_guard: a function that proves its argument is valid@self_guard: a method that proves its receiver is valid