[vala] Deny access to instance members from nullable references



commit 849247ce35903d98d3d2839fd4e3cd1f4d6f21b2
Author: Jürg Billeter <j bitron ch>
Date:   Tue Jun 22 06:42:08 2010 +0200

    Deny access to instance members from nullable references
    
    This only applies to the experimental strict non-null mode.

 vala/valamemberaccess.vala |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 6d12220..2ada89a 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -728,6 +728,11 @@ public class Vala.MemberAccess : Expression {
 				inner.symbol_reference = this_parameter;
 			}
 
+			if (analyzer.context.experimental_non_null && instance && inner.value_type.nullable &&
+			    !(inner.value_type is PointerType) && !(inner.value_type is GenericType)) {
+				Report.error (source_reference, "Access to instance member `%s' from nullable reference denied".printf (symbol_reference.get_full_name ()));
+			}
+
 			formal_value_type = analyzer.get_value_type_for_symbol (symbol_reference, lvalue);
 			if (inner != null && formal_value_type != null) {
 				value_type = formal_value_type.get_actual_type (inner.value_type, null, this);



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