if (expr.value_type != null) {
// FIXME: temporary workaround until the refactoring is complete, not all target_value have a value_type
expr.target_value.value_type = expr.value_type;
-
- if (is_compact_class_destructor_call (expr)) {
- // transfer ownership here and consume given instance
- var temp_value = store_temp_value (expr.target_value, expr);
- ccode.add_assignment (get_cvalue (expr), new CCodeConstant ("NULL"));
- expr.target_value = temp_value;
- } else {
- expr.target_value = transform_value (expr.target_value, expr.target_type, expr);
- }
+ expr.target_value = transform_value (expr.target_value, expr.target_type, expr);
}
if (expr.target_value == null) {
if (!(expr.value_type is ValueType && !expr.value_type.nullable)) {
((GLibValue) expr.target_value).non_null = expr.is_non_null ();
}
+ } else if (expr.value_type != null && is_compact_class_destructor_call (expr)) {
+ // transfer ownership here and consume given instance
+ var temp_value = store_temp_value (expr.target_value, expr);
+ ccode.add_assignment (get_cvalue (expr), new CCodeConstant ("NULL"));
+ expr.target_value = temp_value;
}
}
}
}
-void main () {
+void bar () throws Error {
+}
+
+Foo get_foo () {
+ return new Foo ();
+}
+
+class Bar {
+ Foo faz;
+
+ public void instance_simple () {
+ var foo = new Foo ();
+ var res = foo.destroy ();
+
+ assert (foo == null);
+ assert (res == 42);
+ }
+
+ public void instance_field () {
+ bar ();
+
+ faz = new Foo ();
+ var res = faz.destroy ();
+
+ assert (faz == null);
+ assert (res == 42);
+ }
+}
+
+Foo faz;
+
+void field () {
+ bar ();
+
+ faz = new Foo ();
+ var res = faz.destroy ();
+
+ assert (faz == null);
+ assert (res == 42);
+}
+
+void local () {
+ bar ();
+
var foo = new Foo ();
var res = foo.destroy ();
+
assert (foo == null);
assert (res == 42);
}
+
+void parameter (owned Foo foo) {
+ bar ();
+
+ var res = foo.destroy ();
+
+ assert (foo == null);
+ assert (res == 42);
+}
+
+void simple () {
+ var foo = new Foo ();
+ var res = foo.destroy ();
+
+ assert (foo == null);
+ assert (res == 42);
+}
+
+void returned () {
+ bar ();
+
+ var res = get_foo ().destroy ();
+
+ assert (res == 42);
+}
+
+void main () {
+ simple ();
+ field ();
+ local ();
+ parameter (new Foo ());
+ returned ();
+
+ var bar = new Bar ();
+ bar.instance_simple ();
+ bar.instance_field ();
+}
ma.check_lvalue_access ();
}
}
+
+ if (symbol_reference is Method && ((Method) symbol_reference).get_attribute ("DestroysInstance") != null) {
+ if (ma != null) {
+ ma.lvalue = true;
+ ma.check_lvalue_access ();
+ }
+ }
}
public override void emit (CodeGenerator codegen) {