public int yield_count { get; set; }
+ public bool has_nullable_return_statement { get; set; default = false;}
+
private List<Parameter> parameters = new ArrayList<Parameter> ();
private List<Expression> preconditions;
private List<Expression> postconditions;
if (body != null) {
body.check (context);
+ if (!this.overrides && this.base_interface_method == null &&
+ this.return_type.nullable && !this.has_nullable_return_statement) {
+ // The return type of the method is marked nullable but none
+ // of the return statements return a nullable type
+ Report.warning (this.source_reference, "Return type of %s is marked nullable but none of its return statements return a nullable value".printf (this.get_full_name ()));
+ }
}
if (context.analyzer.current_struct != null) {
Report.warning (source_reference, "`null' incompatible with return type `%s`".printf (context.analyzer.current_return_type.to_string ()));
}
+ if (return_expression.value_type.nullable &&
+ context.analyzer.current_method != null) {
+ context.analyzer.current_method.has_nullable_return_statement = true;
+ }
+
add_error_types (return_expression.get_error_types ());
return !error;