2007-08-30 Jürg Billeter <j@bitron.ch>
+ * vala/valamemberaccess.vala, vala/valasemanticanalyzer.vala: support
+ prototype access to allow accessing instance members without an
+ actual instance, fixes bug 471778
+
+2007-08-30 Jürg Billeter <j@bitron.ch>
+
* vala/valamemberaccessibility.vala: rename MemberAccessibility to
SymbolAccessibility and move its declaration to vala/valasymbol.vala
* vala/parser.y: store accessibility modifier for properties and follow
*/
public string! member_name { get; set; }
+ /**
+ * Represents access to an instance member without an actual instance,
+ * e.g. `MyClass.an_instance_method`.
+ */
+ public bool prototype_access { get; set; }
+
private Expression _inner;
private Gee.List<TypeReference> type_argument_list = new ArrayList<TypeReference> ();
return;
}
+ if (expr.inner is MemberAccess) {
+ var ma = (MemberAccess) expr.inner;
+ if (ma.prototype_access) {
+ expr.error = true;
+ Report.error (expr.source_reference, "Access to instance member `%s' denied".printf (expr.inner.symbol_reference.get_full_name ()));
+ return;
+ }
+ }
+
if (expr.inner is MemberAccess || expr.inner is BaseAccess) {
base_symbol = expr.inner.symbol_reference;
if (base_symbol is Namespace || base_symbol is DataType) {
}
}
if (instance && !may_access_instance_members) {
- expr.error = true;
- Report.error (expr.source_reference, "Access to instance member `%s' denied".printf (member.get_full_name ()));
- return;
+ expr.prototype_access = true;
+ // no static type for prototype access
+ } else {
+ expr.static_type = get_static_type_for_symbol (expr.symbol_reference);
}
current_source_file.add_symbol_dependency (expr.symbol_reference, SourceFileDependencyType.SOURCE);
-
- expr.static_type = get_static_type_for_symbol (expr.symbol_reference);
}
private bool is_type_compatible (TypeReference! expression_type, TypeReference! expected_type) {
return;
}
+ if (expr.call is MemberAccess) {
+ var ma = (MemberAccess) expr.call;
+ if (ma.prototype_access) {
+ expr.error = true;
+ Report.error (expr.source_reference, "Access to instance member `%s' denied".printf (expr.call.symbol_reference.get_full_name ()));
+ return;
+ }
+ }
+
var msym = expr.call.symbol_reference;
if (msym == null) {