From: Jürg Billeter Date: Tue, 22 Jun 2010 04:42:08 +0000 (+0200) Subject: Deny access to instance members from nullable references X-Git-Tag: 0.9.3~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=849247ce35903d98d3d2839fd4e3cd1f4d6f21b2;p=thirdparty%2Fvala.git Deny access to instance members from nullable references This only applies to the experimental strict non-null mode. --- diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala index 6d1222025..2ada89a96 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);