[vala/staging] vala: Treat floating method-return-type as nullable if error may be thrown



commit d6be549d094480e3ec82337bc16df60e99d68366
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Apr 15 13:09:12 2018 +0200

    vala: Treat floating method-return-type as nullable if error may be thrown
    
    https://bugzilla.gnome.org/show_bug.cgi?id=795265

 vala/valamethod.vala     |    1 +
 vala/valamethodcall.vala |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 1adfeab..95bcfbe 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -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");
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index cc6a3fc..41063ba 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]