Correctly handle reference tranfers of inner expressions.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/892
control-flow/assigned-local-variable.vala \
control-flow/break.vala \
control-flow/break-invalid.test \
+ control-flow/coalesce-reference-transfer.vala \
control-flow/continue-invalid.test \
control-flow/double-catch.test \
control-flow/expressions-conditional.vala \
--- /dev/null
+[Compact]
+class Foo {
+ public int i;
+
+ public Foo (int i) {
+ this.i = i;
+ }
+}
+
+Foo? get_foo (int? i) {
+ return i != null ? new Foo (i) : null;
+}
+
+void main () {
+ {
+ Foo foo = get_foo (null) ?? get_foo (42);
+ assert (foo.i == 42);
+ }
+ {
+ Foo foo = get_foo (null) ?? (get_foo (null) ?? get_foo (42));
+ assert (foo.i == 42);
+ }
+}
}
if (operator == BinaryOperator.COALESCE) {
+ if (target_type != null) {
+ left.target_type = target_type.copy ();
+ right.target_type = target_type.copy ();
+ }
+
if (!left.check (context)) {
error = true;
return false;