[vala] Do not warn about unhandled errors of dynamic method calls



commit 68f5b181be5c5c04c5781b375a59aa0a50197682
Author: Jürg Billeter <j bitron ch>
Date:   Sun Sep 13 18:40:20 2009 +0200

    Do not warn about unhandled errors of dynamic method calls
    
    It is impossible to know at compile-time what error types dynamic
    methods may throw, so it does not make sense to warn about possibly
    unhandled errors in this case.
    
    Fixes bug 548439.

 vala/valaerrortype.vala    |    3 +++
 vala/valamemberaccess.vala |    4 +++-
 vala/valamethod.vala       |    2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaerrortype.vala b/vala/valaerrortype.vala
index 69c54b2..d0992e8 100644
--- a/vala/valaerrortype.vala
+++ b/vala/valaerrortype.vala
@@ -37,6 +37,8 @@ public class Vala.ErrorType : ReferenceType {
 	 */
 	public weak ErrorCode? error_code { get; set; }
 
+	public bool dynamic_error { get; set; }
+
 	public ErrorType (ErrorDomain? error_domain, ErrorCode? error_code, SourceReference? source_reference = null) {
 		this.error_domain = error_domain;
 		this.data_type = error_domain;
@@ -86,6 +88,7 @@ public class Vala.ErrorType : ReferenceType {
 		var result = new ErrorType (error_domain, error_code, source_reference);
 		result.value_owned = value_owned;
 		result.nullable = nullable;
+		result.dynamic_error = dynamic_error;
 
 		return result;
 	}
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index a93ed81..d0692c0 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -343,7 +343,9 @@ public class Vala.MemberAccess : Expression {
 						}
 						var m = new DynamicMethod (inner.value_type, member_name, ret_type, source_reference);
 						m.invocation = invoc;
-						m.add_error_type (new ErrorType (null, null));
+						var err = new ErrorType (null, null);
+						err.dynamic_error = true;
+						m.add_error_type (err);
 						m.access = SymbolAccessibility.PUBLIC;
 						m.add_parameter (new FormalParameter.with_ellipsis ());
 						dynamic_object_type.type_symbol.scope.add (null, m);
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 2ef1528..bb4b8ef 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -858,7 +858,7 @@ public class Vala.Method : Member {
 						can_propagate_error = true;
 					}
 				}
-				if (!can_propagate_error) {
+				if (!can_propagate_error && !((ErrorType) body_error_type).dynamic_error) {
 					Report.warning (body_error_type.source_reference, "unhandled error `%s'".printf (body_error_type.to_string()));
 				}
 			}



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