]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Treat floating method-return-type as nullable if error may be thrown
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 15 Apr 2018 11:09:12 +0000 (13:09 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 15 Apr 2018 11:30:17 +0000 (13:30 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=795265

vala/valamethod.vala
vala/valamethodcall.vala

index 1adfeabfd81fa4cdd8553d25b01f0c3a17fc8a12..95bcfbe82f7ef0f324dffe5e18aa9d7123635f70 100644 (file)
@@ -704,6 +704,7 @@ public class Vala.Method : Subroutine, Callable {
                }
                context.analyzer.current_symbol = this;
 
+               return_type.floating_reference = returns_floating_reference;
                return_type.check (context);
 
                var init_attr = get_attribute ("ModuleInit");
index cc6a3fcda9a7248b5aba125cbeae278a24cd1d0b..41063ba3eb32dc2f56878dbb4a4df3a68947313b 100644 (file)
@@ -504,6 +504,10 @@ public class Vala.MethodCall : Expression {
                        if (m.returns_modified_pointer) {
                                ((MemberAccess) call).inner.lvalue = true;
                        }
+                       // avoid passing possible null to ref_sink_function without checking
+                       if (may_throw && !value_type.nullable && value_type.floating_reference && ret_type is ObjectType) {
+                               value_type.nullable = true;
+                       }
 
                        var dynamic_sig = m.parent_symbol as DynamicSignal;
                        if (dynamic_sig != null && dynamic_sig.handler != null) {