There is a warning issued already and this cleans up the AST to prevent
unwanted behaviour in the code-generator, which resulted in the
invocation of "CCodeBaseModule.emit_temp_var()" and criticals like:
vala_ccode_function_add_declaration: assertion 'self != NULL' failed
vala_ccode_function_add_assignment: assertion 'self != NULL' failed
Fixes https://gitlab.gnome.org/GNOME/vala/issues/270
semantic/member-access-capture-out.test \
semantic/member-access-protected-invalid.test \
semantic/member-access-undefined.test \
+ semantic/member-access-static-with-instance.vala \
semantic/method-abstract.test \
semantic/method-abstract-body.test \
semantic/method-async-ref-parameter.test \
--- /dev/null
+struct Foo {
+ public const int FOO = 23;
+
+ public static Foo static_field;
+ public int i;
+}
+
+const int BAR = Foo.static_field.FOO;
+
+void main () {
+ assert (BAR == 23);
+}
// do not warn when calling .begin or .end on static async method
} else {
Report.warning (source_reference, "Access to static member `%s' with an instance reference".printf (symbol_reference.get_full_name ()));
+
+ // Transform to static member access
+ unowned Symbol? inner_sym = symbol_reference.parent_symbol;
+ unowned MemberAccess? inner_ma = this;
+ while (inner_sym != null && inner_sym.name != null) {
+ inner_ma.inner = new MemberAccess (null, inner_sym.name, source_reference);
+ inner_ma = (MemberAccess) inner_ma.inner;
+ inner_sym = inner_sym.parent_symbol;
+ }
+ inner.check (context);
}
}