Up – infer » Nullsafe__InheritanceRuleModule Nullsafe__InheritanceRule
Inheritance rule:
Return type for an overridden method is covariant: overridden method is allowed to narrow down the return value to a subtype of the one from the base method; this means it is OK to make the return value non-null when it was nullable in the base) Parameter type for an overridden method is contravariant. It is OK for a derived method to accept nullable in the params even if the base does not accept nullable. NOTE: Rule 1) is based on Java covariance rule for the return type. In contrast, rule 2) is nullsafe specific as Java does not support type contravariance for method params.
type violation
type type_role
=
val check : type_role -> base:Nullsafe.Nullability.t -> overridden:Nullsafe.Nullability.t -> (unit, violation ) IStdlib.IStd .result
See description of the rule in the header of the file. Note that formal fact of violation might or might not be reported to the user, depending on the mode. See to_reportable_violation
module ReportableViolation : sig ... end
Violation that needs to be reported to the user.