Although this attribute is not meant to be applied on methods of reference
counted classes, the original behaviour should not be changed silently.
Regression of
3d83f31a659bd179e8a867dd054126ac6f22e82b
Fixes https://gitlab.gnome.org/GNOME/vala/issues/873
delegates/bug792077.vala \
objects/chainup.vala \
objects/class_only.vala \
+ objects/class-destroysinstance.vala \
objects/classes.vala \
objects/classes-interfaces.vala \
objects/classes-interfaces-virtuals.vala \
--- /dev/null
+class Foo : Object {
+ [DestroysInstance]
+ public void free () {
+ assert (this.ref_count == 2);
+ this.unref ();
+ }
+}
+
+void main () {
+ var foo = new Foo ();
+ {
+ foo.free ();
+ }
+ assert (foo.ref_count == 1);
+}
}
if (symbol_reference is Method && ((Method) symbol_reference).get_attribute ("DestroysInstance") != null) {
- if (ma != null) {
+ unowned Class? cl = ((Method) symbol_reference).parent_symbol as Class;
+ if (cl != null && cl.is_compact && ma != null) {
ma.lvalue = true;
ma.check_lvalue_access ();
}